All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Matrix.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
23 #define _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <blaze/util/Assert.h>
32 
33 
34 namespace blaze {
35 
36 //=================================================================================================
37 //
38 // CLASS DEFINITION
39 //
40 //=================================================================================================
41 
42 //*************************************************************************************************
53 template< typename MT // Type of the matrix
54  , bool SO > // Storage order
55 struct Matrix
56 {
57  //**Type definitions****************************************************************************
58  typedef MT MatrixType;
59  //**********************************************************************************************
60 
61  //**Non-const conversion operator***************************************************************
66  inline MatrixType& operator~() {
67  return *static_cast<MatrixType*>( this );
68  }
69  //**********************************************************************************************
70 
71  //**Const conversion operator*******************************************************************
76  inline const MatrixType& operator~() const {
77  return *static_cast<const MatrixType*>( this );
78  }
79  //**********************************************************************************************
80 };
81 //*************************************************************************************************
82 
83 
84 
85 
86 //=================================================================================================
87 //
88 // GLOBAL FUNCTIONS
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
95 template< typename MT, bool SO >
96 inline size_t rows( const Matrix<MT,SO>& m );
97 
98 template< typename MT, bool SO >
99 inline size_t columns( const Matrix<MT,SO>& m );
100 
101 template< typename MT1, bool SO1, typename MT2, bool SO2 >
102 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
103 
104 template< typename MT1, bool SO1, typename MT2, bool SO2 >
105 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
106 
107 template< typename MT1, bool SO1, typename MT2, bool SO2 >
108 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
109 
110 template< typename MT1, bool SO1, typename MT2, bool SO2 >
111 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
113 //*************************************************************************************************
114 
115 
116 //*************************************************************************************************
123 template< typename MT // Type of the matrix
124  , bool SO > // Storage order of the matrix
125 inline size_t rows( const Matrix<MT,SO>& m )
126 {
127  return (~m).rows();
128 }
129 //*************************************************************************************************
130 
131 
132 //*************************************************************************************************
139 template< typename MT // Type of the matrix
140  , bool SO > // Storage order of the matrix
141 inline size_t columns( const Matrix<MT,SO>& m )
142 {
143  return (~m).columns();
144 }
145 //*************************************************************************************************
146 
147 
148 //*************************************************************************************************
162 template< typename MT1 // Type of the left-hand side matrix
163  , bool SO1 // Storage order of the left-hand side matrix
164  , typename MT2 // Type of the right-hand side matrix
165  , bool SO2 > // Storage order of the right-hand side matrix
166 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
167 {
169 
170  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
171  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
172 
173  (~lhs).assign( ~rhs );
174 }
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
192 template< typename MT1 // Type of the left-hand side matrix
193  , bool SO1 // Storage order of the left-hand side matrix
194  , typename MT2 // Type of the right-hand side matrix
195  , bool SO2 > // Storage order of the right-hand side matrix
196 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
197 {
199 
200  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
201  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
202 
203  (~lhs).addAssign( ~rhs );
204 }
205 //*************************************************************************************************
206 
207 
208 //*************************************************************************************************
222 template< typename MT1 // Type of the left-hand side matrix
223  , bool SO1 // Storage order of the left-hand side matrix
224  , typename MT2 // Type of the right-hand side matrix
225  , bool SO2 > // Storage order of the right-hand side matrix
226 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
227 {
229 
230  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
231  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
232 
233  (~lhs).subAssign( ~rhs );
234 }
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
252 template< typename MT1 // Type of the left-hand side matrix
253  , bool SO1 // Storage order of the left-hand side matrix
254  , typename MT2 // Type of the right-hand side matrix
255  , bool SO2 > // Storage order of the right-hand side matrix
256 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
257 {
259 
260  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
261 
262  (~lhs).multAssign( ~rhs );
263 }
264 //*************************************************************************************************
265 
266 } // namespace blaze
267 
268 #endif