40 template<
typename ResultDataType,
typename LhsDataType,
typename LhsMatrixType>
43 const ResultDataType&
rhs)
46 int n =
lhs.GetRows();
47 int m =
lhs.GetColumns();
48 for(
unsigned int i = 0; i < n; ++i)
50 for(
unsigned int j = 0; j < m; ++j)
52 result(i,j) =
lhs(i,j)*
rhs;
74 const ResultDataType&
lhs,
99 for( iterator iter =
lhs.begin(); iter !=
lhs.end(); ++iter)
113 ASSERTL1(
lhs.GetColumns() ==
rhs.GetRows(), std::string(
"A left side matrix with column count ") +
114 std::to_string(
lhs.GetColumns()) +
115 std::string(
" and a right side matrix with row count ") +
116 std::to_string(
rhs.GetRows()) + std::string(
" can't be multiplied."));
118 for(
unsigned int i = 0; i < result.GetRows(); ++i)
120 for(
unsigned int j = 0; j < result.GetColumns(); ++j)
122 ResultType t = ResultType(0);
125 for(
unsigned int k = 0; k <
lhs.GetColumns(); ++k)
149 ASSERTL1(
lhs.GetColumns() ==
rhs.GetRows(), std::string(
"A left side matrix with column count ") +
150 std::to_string(
lhs.GetColumns()) +
151 std::string(
" and a right side matrix with row count ") +
152 std::to_string(
rhs.GetRows()) + std::string(
" can't be multiplied."));
171 ASSERTL1(result.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
172 std::to_string(result.GetRows()) + std::string(
" and ") +
173 std::to_string(
rhs.GetRows()) + std::string(
" can't be added."));
174 ASSERTL1(result.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
175 std::to_string(result.GetColumns()) + std::string(
" and ") +
176 std::to_string(
rhs.GetColumns()) + std::string(
" can't be added."));
178 for(
unsigned int i = 0; i <
rhs.GetRows(); ++i)
180 for(
unsigned int j = 0; j <
rhs.GetColumns(); ++j)
182 result(i,j) +=
rhs(i,j);
188 template<
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
192 ASSERTL1(result.
GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
193 std::to_string(result.
GetRows()) + std::string(
" and ") +
194 std::to_string(
rhs.GetRows()) + std::string(
" can't be added."));
195 ASSERTL1(result.
GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
196 std::to_string(result.
GetColumns()) + std::string(
" and ") +
197 std::to_string(
rhs.GetColumns()) + std::string(
" can't be added."));
199 for(
unsigned int i = 0; i <
rhs.GetRows(); ++i)
201 for(
unsigned int j = 0; j <
rhs.GetColumns(); ++j)
203 result(i,j) = -result(i,j) +
rhs(i,j);
217 ASSERTL1(
lhs.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
218 std::to_string(
lhs.GetRows()) + std::string(
" and ") +
219 std::to_string(
rhs.GetRows()) + std::string(
" can't be added."));
220 ASSERTL1(
lhs.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
221 std::to_string(
lhs.GetColumns()) + std::string(
" and ") +
222 std::to_string(
rhs.GetColumns()) + std::string(
" can't be added."));
224 for(
unsigned int i = 0; i <
lhs.GetRows(); ++i)
226 for(
unsigned int j = 0; j <
lhs.GetColumns(); ++j)
228 result(i,j) =
lhs(i,j) +
rhs(i,j);
233 template<
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
typename RhsDataType,
typename RhsMatrixType>
238 ASSERTL1(
lhs.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
239 std::to_string(
lhs.GetRows()) + std::string(
" and ") +
240 std::to_string(
rhs.GetRows()) + std::string(
" can't be added."));
241 ASSERTL1(
lhs.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
242 std::to_string(
lhs.GetColumns()) + std::string(
" and ") +
243 std::to_string(
rhs.GetColumns()) + std::string(
" can't be added."));
245 for(
unsigned int i = 0; i <
lhs.GetRows(); ++i)
247 for(
unsigned int j = 0; j <
lhs.GetColumns(); ++j)
249 result(i,j) = -
lhs(i,j) +
rhs(i,j);
276 ASSERTL1(
lhs.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
277 std::to_string(
lhs.GetRows()) + std::string(
" and ") +
278 std::to_string(
rhs.GetRows()) + std::string(
" can't be subtracted."));
279 ASSERTL1(
lhs.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
280 std::to_string(
lhs.GetColumns()) + std::string(
" and ") +
281 std::to_string(
rhs.GetColumns()) + std::string(
" can't be subtracted."));
283 for(
unsigned int i = 0; i <
lhs.GetRows(); ++i)
285 for(
unsigned int j = 0; j <
lhs.GetColumns(); ++j)
287 result(i,j) =
lhs(i,j) -
rhs(i,j);
292 template<
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
typename RhsDataType,
typename RhsMatrixType>
297 ASSERTL1(
lhs.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
298 std::to_string(
lhs.GetRows()) + std::string(
" and ") +
299 std::to_string(
rhs.GetRows()) + std::string(
" can't be subtracted."));
300 ASSERTL1(
lhs.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
301 std::to_string(
lhs.GetColumns()) + std::string(
" and ") +
302 std::to_string(
rhs.GetColumns()) + std::string(
" can't be subtracted."));
304 for(
unsigned int i = 0; i <
lhs.GetRows(); ++i)
306 for(
unsigned int j = 0; j <
lhs.GetColumns(); ++j)
308 result(i,j) = -
lhs(i,j) -
rhs(i,j);
322 ASSERTL1(result.GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
323 std::to_string(result.GetRows()) + std::string(
" and ") +
324 std::to_string(
rhs.GetRows()) + std::string(
" can't be subtracted."));
325 ASSERTL1(result.GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
326 std::to_string(result.GetColumns()) + std::string(
" and ") +
327 std::to_string(
rhs.GetColumns()) + std::string(
" can't be subtracted."));
329 for(
unsigned int i = 0; i <
rhs.GetRows(); ++i)
331 for(
unsigned int j = 0; j <
rhs.GetColumns(); ++j)
333 result(i,j) -=
rhs(i,j);
338 template<
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
342 ASSERTL1(result.
GetRows() ==
rhs.GetRows(), std::string(
"Matrices with different row counts ") +
343 std::to_string(result.
GetRows()) + std::string(
" and ") +
344 std::to_string(
rhs.GetRows()) + std::string(
" can't be subtracted."));
345 ASSERTL1(result.
GetColumns() ==
rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
346 std::to_string(result.
GetColumns()) + std::string(
" and ") +
347 std::to_string(
rhs.GetColumns()) + std::string(
" can't be subtracted."));
349 for(
unsigned int i = 0; i <
rhs.GetRows(); ++i)
351 for(
unsigned int j = 0; j <
rhs.GetColumns(); ++j)
353 result(i,j) = -result(i,j) -
rhs(i,j);
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
unsigned int GetRows() const
unsigned int GetColumns() const
void SetSize(unsigned int rows, unsigned int cols)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
void AddEqualNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
RhsMatrixType void NekMultiplyDefaultImpl(NekMatrix< ResultType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
RhsMatrixType void AddEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
RhsMatrixType void Subtract(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void Multiply(NekMatrix< ResultDataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const ResultDataType &rhs)
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES(Multiply, NEKTAR_ALL_MATRIX_TYPES, NEKTAR_ALL_MATRIX_TYPES,(1,(void)),(1,(DNekMat &)),(0,())) template< typename DataType
void NekMultiplyFullMatrixFullMatrix(NekMatrix< ResultType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void MultiplyEqual(NekMatrix< LhsDataType, StandardMatrixTag > &lhs, typename boost::call_traits< LhsDataType >::const_reference rhs)
void AddNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void SubtractEqualNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_SINGLE_MATRIX(Multiply, NEKTAR_ALL_MATRIX_TYPES,(1,(void)),(1,(DNekMat &)),(1,(const NekDouble &))) template< typename DataType
void SubtractNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
DNekMat void Add(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
DNekMat void SubtractEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)