All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Matrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
36 #define _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/Assert.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
66 template< typename MT // Type of the matrix
67  , bool SO > // Storage order
68 struct Matrix
69 {
70  //**Type definitions****************************************************************************
71  typedef MT MatrixType;
72  //**********************************************************************************************
73 
74  //**Non-const conversion operator***************************************************************
79  inline MatrixType& operator~() {
80  return *static_cast<MatrixType*>( this );
81  }
82  //**********************************************************************************************
83 
84  //**Const conversion operator*******************************************************************
89  inline const MatrixType& operator~() const {
90  return *static_cast<const MatrixType*>( this );
91  }
92  //**********************************************************************************************
93 };
94 //*************************************************************************************************
95 
96 
97 
98 
99 //=================================================================================================
100 //
101 // GLOBAL FUNCTIONS
102 //
103 //=================================================================================================
104 
105 //*************************************************************************************************
108 template< typename MT, bool SO >
109 inline size_t rows( const Matrix<MT,SO>& m );
110 
111 template< typename MT, bool SO >
112 inline size_t columns( const Matrix<MT,SO>& m );
113 
114 template< typename MT1, bool SO1, typename MT2, bool SO2 >
115 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
116 
117 template< typename MT1, bool SO1, typename MT2, bool SO2 >
118 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
119 
120 template< typename MT1, bool SO1, typename MT2, bool SO2 >
121 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
122 
123 template< typename MT1, bool SO1, typename MT2, bool SO2 >
124 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
126 //*************************************************************************************************
127 
128 
129 //*************************************************************************************************
136 template< typename MT // Type of the matrix
137  , bool SO > // Storage order of the matrix
138 inline size_t rows( const Matrix<MT,SO>& m )
139 {
140  return (~m).rows();
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
152 template< typename MT // Type of the matrix
153  , bool SO > // Storage order of the matrix
154 inline size_t columns( const Matrix<MT,SO>& m )
155 {
156  return (~m).columns();
157 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
175 template< typename MT1 // Type of the left-hand side matrix
176  , bool SO1 // Storage order of the left-hand side matrix
177  , typename MT2 // Type of the right-hand side matrix
178  , bool SO2 > // Storage order of the right-hand side matrix
179 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
180 {
182 
183  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
184  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
185 
186  (~lhs).assign( ~rhs );
187 }
188 //*************************************************************************************************
189 
190 
191 //*************************************************************************************************
205 template< typename MT1 // Type of the left-hand side matrix
206  , bool SO1 // Storage order of the left-hand side matrix
207  , typename MT2 // Type of the right-hand side matrix
208  , bool SO2 > // Storage order of the right-hand side matrix
209 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
210 {
212 
213  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
214  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
215 
216  (~lhs).addAssign( ~rhs );
217 }
218 //*************************************************************************************************
219 
220 
221 //*************************************************************************************************
235 template< typename MT1 // Type of the left-hand side matrix
236  , bool SO1 // Storage order of the left-hand side matrix
237  , typename MT2 // Type of the right-hand side matrix
238  , bool SO2 > // Storage order of the right-hand side matrix
239 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
240 {
242 
243  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
244  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
245 
246  (~lhs).subAssign( ~rhs );
247 }
248 //*************************************************************************************************
249 
250 
251 //*************************************************************************************************
265 template< typename MT1 // Type of the left-hand side matrix
266  , bool SO1 // Storage order of the left-hand side matrix
267  , typename MT2 // Type of the right-hand side matrix
268  , bool SO2 > // Storage order of the right-hand side matrix
269 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
270 {
272 
273  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
274 
275  (~lhs).multAssign( ~rhs );
276 }
277 //*************************************************************************************************
278 
279 } // namespace blaze
280 
281 #endif
MT MatrixType
Type of the matrix.
Definition: Matrix.h:71
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:269
Header file for run time assertion macros.
MatrixType & operator~()
Conversion operator for non-constant matrices.
Definition: Matrix.h:79
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
const MatrixType & operator~() const
Conversion operator for constant matrices.
Definition: Matrix.h:89
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the FunctionTrace class.