cheshirekow  v0.1.0
StreamAssignment.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_STREAMASSIGNMENT_H_
28 #define MPBLOCKS_CUDA_POLYMOMIAL_STREAMASSIGNMENT_H_
29 
30 #include <iostream>
31 #include <cassert>
33 
34 namespace mpblocks {
35 namespace cuda {
36 namespace polynomial {
37 
38 
39 
40 template< int idx, typename Scalar, class Exp1 >
42 Scalar& set_storage( Exp1& );
43 
44 
46 template <class Scalar, class Exp, int idx>
48 {
49  private:
50  Exp& m_exp;
51 
52  public:
54  StreamAssignment( Exp& exp ):
55  m_exp(exp)
56  {}
57 
58  template <typename Scalar2>
61  {
62  set_storage<idx>(m_exp) = x;
64  }
65 
66  template <typename Scalar2>
69  {
70  return append<Scalar>(x);
71  }
72 };
73 
74 template <typename Scalar, class Exp, typename Scalar2>
76 StreamAssignment<Scalar,Exp,1> operator<<( LValue<Scalar,Exp>& exp, const Scalar2& val )
77 {
78  set_storage<0>( static_cast<Exp&>(exp) ) = val;
79  return StreamAssignment<Scalar,Exp,1>( static_cast<Exp&>(exp) );
80 }
81 
82 } // polynomial
83 } // cuda
84 } // mpblocks
85 
86 
87 
88 
89 
90 #endif // POLYMOMIAL_H_
__host__ __device__ StreamAssignment< Scalar, Exp, idx+1 > operator,(Scalar2 x)
#define __device__
Definition: fakecuda.h:34
__host__ __device__ StreamAssignment(Exp &exp)
#define __host__
Definition: fakecuda.h:37
__host__ __device__ StreamAssignment< Scalar, Exp, idx+1 > append(Scalar2 x)
__host__ __device__ __forceinline__ Scalar & set_storage(Polynomial< Scalar, Spec > &poly)
Definition: Polynomial.h:385