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>
31 
32 
33 namespace blaze {
34 
35 //=================================================================================================
36 //
37 // CLASS DEFINITION
38 //
39 //=================================================================================================
40 
41 //*************************************************************************************************
52 template< typename MT // Type of the matrix
53  , bool SO > // Storage order
54 struct Matrix
55 {
56  //**Type definitions****************************************************************************
57  typedef MT MatrixType;
58  //**********************************************************************************************
59 
60  //**Non-const conversion operator***************************************************************
65  inline MatrixType& operator~() {
66  return *static_cast<MatrixType*>( this );
67  }
68  //**********************************************************************************************
69 
70  //**Const conversion operator*******************************************************************
75  inline const MatrixType& operator~() const {
76  return *static_cast<const MatrixType*>( this );
77  }
78  //**********************************************************************************************
79 };
80 //*************************************************************************************************
81 
82 
83 
84 
85 //=================================================================================================
86 //
87 // GLOBAL FUNCTIONS
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
94 template< typename MT, bool SO >
95 inline size_t rows( const Matrix<MT,SO>& m );
96 
97 template< typename MT, bool SO >
98 inline size_t columns( const Matrix<MT,SO>& m );
99 
100 template< typename MT1, bool SO1, typename MT2, bool SO2 >
101 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
102 
103 template< typename MT1, bool SO1, typename MT2, bool SO2 >
104 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
105 
106 template< typename MT1, bool SO1, typename MT2, bool SO2 >
107 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
108 
109 template< typename MT1, bool SO1, typename MT2, bool SO2 >
110 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs );
112 //*************************************************************************************************
113 
114 
115 //*************************************************************************************************
122 template< typename MT // Type of the matrix
123  , bool SO > // Storage order of the matrix
124 inline size_t rows( const Matrix<MT,SO>& m )
125 {
126  return (~m).rows();
127 }
128 //*************************************************************************************************
129 
130 
131 //*************************************************************************************************
138 template< typename MT // Type of the matrix
139  , bool SO > // Storage order of the matrix
140 inline size_t columns( const Matrix<MT,SO>& m )
141 {
142  return (~m).columns();
143 }
144 //*************************************************************************************************
145 
146 
147 //*************************************************************************************************
161 template< typename MT1 // Type of the left-hand side matrix
162  , bool SO1 // Storage order of the left-hand side matrix
163  , typename MT2 // Type of the right-hand side matrix
164  , bool SO2 > // Storage order of the right-hand side matrix
165 inline void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
166 {
167  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
168  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
169 
170  (~lhs).assign( ~rhs );
171 }
172 //*************************************************************************************************
173 
174 
175 //*************************************************************************************************
189 template< typename MT1 // Type of the left-hand side matrix
190  , bool SO1 // Storage order of the left-hand side matrix
191  , typename MT2 // Type of the right-hand side matrix
192  , bool SO2 > // Storage order of the right-hand side matrix
193 inline void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
194 {
195  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
196  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
197 
198  (~lhs).addAssign( ~rhs );
199 }
200 //*************************************************************************************************
201 
202 
203 //*************************************************************************************************
217 template< typename MT1 // Type of the left-hand side matrix
218  , bool SO1 // Storage order of the left-hand side matrix
219  , typename MT2 // Type of the right-hand side matrix
220  , bool SO2 > // Storage order of the right-hand side matrix
221 inline void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
222 {
223  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
224  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
225 
226  (~lhs).subAssign( ~rhs );
227 }
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
245 template< typename MT1 // Type of the left-hand side matrix
246  , bool SO1 // Storage order of the left-hand side matrix
247  , typename MT2 // Type of the right-hand side matrix
248  , bool SO2 > // Storage order of the right-hand side matrix
249 inline void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
250 {
251  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
252 
253  (~lhs).multAssign( ~rhs );
254 }
255 //*************************************************************************************************
256 
257 } // namespace blaze
258 
259 #endif