cheshirekow  v0.1.0
assign.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_CUDA_POLYNOMIAL_ASSIGN_H_
28 #define MPBLOCKS_CUDA_POLYNOMIAL_ASSIGN_H_
29 
30 namespace mpblocks {
31 namespace cuda {
32 namespace polynomial {
33 
34 
35 template< bool Enable, typename Scalar, class Spec, class Exp, int idx >
36 struct Assign
37 {
39  static void step( Polynomial<Scalar,Spec>& p, const Exp& exp ){}
40 };
41 
42 
43 template< typename Scalar, class Spec, class Exp, int idx >
44 struct Assign< true, Scalar, Spec, Exp, idx >
45 {
47  static void step( Polynomial<Scalar,Spec>& p, const Exp& exp )
48  {
49  set<idx>(p) = get<idx>(exp);
50  }
51 };
52 
53 template< typename Scalar, class Spec, class Exp >
55 void assign( Polynomial<Scalar,Spec>& p, const Exp& exp )
56 {
57  Assign< intlist::contains<Spec,0>::value, Scalar, Spec, Exp, 0 >::step(p,exp);
58  Assign< intlist::contains<Spec,1>::value, Scalar, Spec, Exp, 1 >::step(p,exp);
59  Assign< intlist::contains<Spec,2>::value, Scalar, Spec, Exp, 2 >::step(p,exp);
60  Assign< intlist::contains<Spec,3>::value, Scalar, Spec, Exp, 3 >::step(p,exp);
61  Assign< intlist::contains<Spec,4>::value, Scalar, Spec, Exp, 4 >::step(p,exp);
62  Assign< intlist::contains<Spec,5>::value, Scalar, Spec, Exp, 5 >::step(p,exp);
63  Assign< intlist::contains<Spec,6>::value, Scalar, Spec, Exp, 6 >::step(p,exp);
64  Assign< intlist::contains<Spec,7>::value, Scalar, Spec, Exp, 7 >::step(p,exp);
65  Assign< intlist::contains<Spec,8>::value, Scalar, Spec, Exp, 8 >::step(p,exp);
66  Assign< intlist::contains<Spec,9>::value, Scalar, Spec, Exp, 9 >::step(p,exp);
67 };
68 
69 
70 
71 
72 
73 
74 
75 } // polynomial
76 } // cuda
77 } // mpblocks
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 #endif // ASSIGN_H_
A sparse, statically sized polynomial.
Definition: Polynomial.h:266
#define __forceinline__
Definition: fakecuda.h:38
__host__ __device__ static __forceinline__ void step(Polynomial< Scalar, Spec > &p, const Exp &exp)
Definition: assign.h:47
#define __device__
Definition: fakecuda.h:34
#define __host__
Definition: fakecuda.h:37
__host__ __device__ __forceinline__ void assign(Polynomial< Scalar, Spec > &p, const Exp &exp)
Definition: assign.h:55
__host__ __device__ static __forceinline__ void step(Polynomial< Scalar, Spec > &p, const Exp &exp)
Definition: assign.h:39