cheshirekow  v0.1.0
RValue.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_RVALUE_H_
28 #define MPBLOCKS_CUDA_LINALG2_RVALUE_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 RValue
37 {
38  public:
40  template< Size_t i >
42  Scalar ve()
43  {
44  return static_cast<Exp const&>(*this).Exp::template ve<i>();
45  }
46 
48  template< Size_t i, Size_t j >
50  Scalar me()
51  {
52  std::cout << "RValue: returning (" << i << "," << j << ") component\n";
53  return static_cast<Exp const&>(*this).Exp::template me<i,j>();
54  }
55 
56 };
57 
58 
59 
60 
61 
62 } // linalg
63 } // cuda
64 } // mpblocks
65 
66 
67 
68 
69 
70 #endif // MATRIXEXPRESSION_H_
__device__ __host__ Scalar me()
return the evaluated (i,j)'th element of a matrix expression
Definition: RValue.h:50
expression template for rvalues
Definition: RValue.h:36
#define __device__
Definition: fakecuda.h:34
#define __host__
Definition: fakecuda.h:37
__device__ __host__ Scalar ve()
return the evaluated i'th element of a vector expression
Definition: RValue.h:42