cheshirekow  v0.1.0
LValue.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_LINALG2_LVALUE_H_
28 #define MPBLOCKS_CUDA_LINALG2_LVALUE_H_
29 
30 namespace mpblocks {
31 namespace cuda {
32 namespace linalg2 {
33 
35 template <typename Scalar, Size_t ROWS, Size_t COLS, class Exp>
36 class LValue
37 {
38  public:
41  template< Size_t i >
43  Scalar& ve()
44  {
45  return static_cast<Exp&>(*this).Exp::template ve<i>();
46  }
47 
50  template< Size_t i >
52  Scalar const& ve() const
53  {
54  return static_cast<Exp const&>(*this).Exp::template ve<i>();
55  }
56 
59  template< Size_t i, Size_t j >
61  Scalar& me()
62  {
63  return static_cast<Exp&>(*this).Exp::template me<i,j>();
64  }
65 
68  template< Size_t i, Size_t j >
70  Scalar const& me() const
71  {
72  return static_cast<Exp const&>(*this).Exp::template me<i,j>();
73  }
74 
76  template< typename Exp2 >
80  {
82  static_cast<Exp&>(*this),
83  static_cast<Exp2 const&>(B) );
84 
85  return *this;
86  }
87 
91  operator<<( Scalar x )
92  {
93  me<0,0>() = x;
95  static_cast<Exp&>(*this) );
96  }
97 };
98 
99 
100 
101 
102 
103 } // linalg
104 } // cuda
105 } // mpblocks
106 
107 
108 
109 
110 
111 #endif // MATRIXEXPRESSION_H_
__device__ __host__ Scalar const & ve() const
return an immutable reference to the i'th element of the vector expression
Definition: LValue.h:52
expression template for rvalues
Definition: RValue.h:36
__device__ __host__ Scalar const & me() const
return an immutable reference to the (i,j)th element of the matrix expression
Definition: LValue.h:70
__device__ __host__ AssignmentIterator< Scalar, ROWS, COLS, 0, 1, Exp > operator<<(Scalar x)
return an assignment iterator
Definition: LValue.h:91
__device__ __host__ LValue< Scalar, ROWS, COLS, Exp > & operator=(RValue< Scalar, ROWS, COLS, Exp2 > const &B)
assignment
Definition: LValue.h:78
__device__ __host__ Scalar & me()
return a mutable reference to the (i,j)th element of the matrix expression
Definition: LValue.h:61
#define __device__
Definition: fakecuda.h:34
#define __host__
Definition: fakecuda.h:37
__device__ static __host__ void doit(Exp1 &A, Exp2 const &B)
Definition: Assignment.h:99
expression template for rvalues
Definition: LValue.h:36
__device__ __host__ Scalar & ve()
return a mutable reference to the i'th element of the vector expression
Definition: LValue.h:43