40template <
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;
64template <
typename DataType,
typename LhsDataType,
typename LhsMatrixType>
84template <
typename RhsDataType,
typename RhsMatrixType,
typename ResultDataType>
86 const ResultDataType &lhs,
100template <typename DataType, typename RhsDataType, typename RhsMatrixType>
116template <typename LhsDataType>
118 NekMatrix<LhsDataType, StandardMatrixTag> &lhs,
119 typename
boost::call_traits<LhsDataType>::const_reference rhs)
123 for (iterator iter = lhs.begin(); iter != lhs.end(); ++iter)
136template <
typename ResultType,
typename LhsDataType,
typename RhsDataType,
137 typename LhsMatrixType,
typename RhsMatrixType>
142 ASSERTL1(lhs.GetColumns() == rhs.GetRows(),
143 std::string(
"A left side matrix with column count ") +
144 std::to_string(lhs.GetColumns()) +
145 std::string(
" and a right side matrix with row count ") +
146 std::to_string(rhs.GetRows()) +
147 std::string(
" can't be multiplied."));
149 for (
unsigned int i = 0; i < result.GetRows(); ++i)
151 for (
unsigned int j = 0; j < result.GetColumns(); ++j)
153 ResultType t = ResultType(0);
156 for (
unsigned int k = 0; k < lhs.GetColumns(); ++k)
158 t += lhs(i, k) * rhs(k, j);
165template <
typename ResultType,
typename LhsDataType,
typename RhsDataType,
166 typename LhsMatrixType,
typename RhsMatrixType>
175template <
typename LhsDataType,
typename RhsDataType,
typename DataType,
176 typename LhsMatrixType,
typename RhsMatrixType>
181 ASSERTL1(lhs.GetColumns() == rhs.GetRows(),
182 std::string(
"A left side matrix with column count ") +
183 std::to_string(lhs.GetColumns()) +
184 std::string(
" and a right side matrix with row count ") +
185 std::to_string(rhs.GetRows()) +
186 std::string(
" can't be multiplied."));
188 result.
SetSize(lhs.GetRows(), rhs.GetColumns());
189 if (lhs.GetType() ==
eFULL && rhs.GetType() ==
eFULL)
204 (1, (
void)), (1, (
SNekMat &)), (0, ()))
206template <typename DataType, typename RhsDataType, typename RhsMatrixType>
208 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
210 ASSERTL1(result.GetRows() == rhs.GetRows(),
211 std::string(
"Matrices with different row counts ") +
212 std::to_string(result.GetRows()) + std::string(
" and ") +
213 std::to_string(rhs.GetRows()) +
214 std::string(
" can't be added."));
215 ASSERTL1(result.GetColumns() == rhs.GetColumns(),
216 std::string(
"Matrices with different column counts ") +
217 std::to_string(result.GetColumns()) + std::string(
" and ") +
218 std::to_string(rhs.GetColumns()) +
219 std::string(
" can't be added."));
221 for (
unsigned int i = 0; i < rhs.GetRows(); ++i)
223 for (
unsigned int j = 0; j < rhs.GetColumns(); ++j)
225 result(i, j) += rhs(i, j);
230template <
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
235 std::string(
"Matrices with different row counts ") +
236 std::to_string(result.
GetRows()) + std::string(
" and ") +
237 std::to_string(rhs.GetRows()) +
238 std::string(
" can't be added."));
240 std::string(
"Matrices with different column counts ") +
241 std::to_string(result.
GetColumns()) + std::string(
" and ") +
242 std::to_string(rhs.GetColumns()) +
243 std::string(
" can't be added."));
245 for (
unsigned int i = 0; i < rhs.GetRows(); ++i)
247 for (
unsigned int j = 0; j < rhs.GetColumns(); ++j)
249 result(i, j) = -result(i, j) + rhs(i, j);
266template <typename DataType, typename LhsDataType, typename LhsMatrixType,
267 typename RhsDataType, typename RhsMatrixType>
269 const
NekMatrix<LhsDataType, LhsMatrixType> &lhs,
270 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
272 ASSERTL1(lhs.GetRows() == rhs.GetRows(),
273 std::string(
"Matrices with different row counts ") +
274 std::to_string(lhs.GetRows()) + std::string(
" and ") +
275 std::to_string(rhs.GetRows()) +
276 std::string(
" can't be added."));
277 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(),
278 std::string(
"Matrices with different column counts ") +
279 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
280 std::to_string(rhs.GetColumns()) +
281 std::string(
" can't be added."));
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);
292template <
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
293 typename RhsDataType,
typename RhsMatrixType>
298 ASSERTL1(lhs.GetRows() == rhs.GetRows(),
299 std::string(
"Matrices with different row counts ") +
300 std::to_string(lhs.GetRows()) + std::string(
" and ") +
301 std::to_string(rhs.GetRows()) +
302 std::string(
" can't be added."));
303 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(),
304 std::string(
"Matrices with different column counts ") +
305 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
306 std::to_string(rhs.GetColumns()) +
307 std::string(
" can't be added."));
309 for (
unsigned int i = 0; i < lhs.GetRows(); ++i)
311 for (
unsigned int j = 0; j < lhs.GetColumns(); ++j)
313 result(i, j) = -lhs(i, j) + rhs(i, j);
323 (1, (
void)), (1, (
SNekMat &)), (0, ()))
326 (1, (
void)), (1, (
DNekMat &)), (0, ()))
331template <typename LhsDataType, typename LhsMatrixType, typename RhsDataType,
332 typename RhsMatrixType>
336 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
342 Add(result, lhs, rhs);
351 (1, (
SNekMat)), (0, ()), (0, ()))
353template <typename DataType, typename LhsDataType, typename LhsMatrixType,
354 typename RhsDataType, typename RhsMatrixType>
356 const
NekMatrix<LhsDataType, LhsMatrixType> &lhs,
357 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
359 ASSERTL1(lhs.GetRows() == rhs.GetRows(),
360 std::string(
"Matrices with different row counts ") +
361 std::to_string(lhs.GetRows()) + std::string(
" and ") +
362 std::to_string(rhs.GetRows()) +
363 std::string(
" can't be subtracted."));
364 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(),
365 std::string(
"Matrices with different column counts ") +
366 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
367 std::to_string(rhs.GetColumns()) +
368 std::string(
" can't be subtracted."));
370 for (
unsigned int i = 0; i < lhs.GetRows(); ++i)
372 for (
unsigned int j = 0; j < lhs.GetColumns(); ++j)
374 result(i, j) = lhs(i, j) - rhs(i, j);
379template <
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
380 typename RhsDataType,
typename RhsMatrixType>
385 ASSERTL1(lhs.GetRows() == rhs.GetRows(),
386 std::string(
"Matrices with different row counts ") +
387 std::to_string(lhs.GetRows()) + std::string(
" and ") +
388 std::to_string(rhs.GetRows()) +
389 std::string(
" can't be subtracted."));
390 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(),
391 std::string(
"Matrices with different column counts ") +
392 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
393 std::to_string(rhs.GetColumns()) +
394 std::string(
" can't be subtracted."));
396 for (
unsigned int i = 0; i < lhs.GetRows(); ++i)
398 for (
unsigned int j = 0; j < lhs.GetColumns(); ++j)
400 result(i, j) = -lhs(i, j) - rhs(i, j);
410 (1, (
void)), (1, (
SNekMat &)), (0, ()))
413 (1, (
void)), (1, (
DNekMat &)), (0, ()))
418template <typename DataType, typename RhsDataType, typename RhsMatrixType>
420 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
422 ASSERTL1(result.GetRows() == rhs.GetRows(),
423 std::string(
"Matrices with different row counts ") +
424 std::to_string(result.GetRows()) + std::string(
" and ") +
425 std::to_string(rhs.GetRows()) +
426 std::string(
" can't be subtracted."));
427 ASSERTL1(result.GetColumns() == rhs.GetColumns(),
428 std::string(
"Matrices with different column counts ") +
429 std::to_string(result.GetColumns()) + std::string(
" and ") +
430 std::to_string(rhs.GetColumns()) +
431 std::string(
" can't be subtracted."));
433 for (
unsigned int i = 0; i < rhs.GetRows(); ++i)
435 for (
unsigned int j = 0; j < rhs.GetColumns(); ++j)
437 result(i, j) -= rhs(i, j);
442template <
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
447 std::string(
"Matrices with different row counts ") +
448 std::to_string(result.
GetRows()) + std::string(
" and ") +
449 std::to_string(rhs.GetRows()) +
450 std::string(
" can't be subtracted."));
452 std::string(
"Matrices with different column counts ") +
453 std::to_string(result.
GetColumns()) + std::string(
" and ") +
454 std::to_string(rhs.GetColumns()) +
455 std::string(
" can't be subtracted."));
457 for (
unsigned int i = 0; i < rhs.GetRows(); ++i)
459 for (
unsigned int j = 0; j < rhs.GetColumns(); ++j)
461 result(i, j) = -result(i, j) - rhs(i, j);
479template <typename LhsDataType, typename LhsMatrixType, typename RhsDataType,
480 typename RhsMatrixType>
484 const
NekMatrix<RhsDataType, RhsMatrixType> &rhs)
499 (1, (
SNekMat)), (0, ()), (0, ()))
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define NEKTAR_ALL_MATRIX_TYPES
unsigned int GetRows() const
unsigned int GetColumns() const
void SetSize(unsigned int rows, unsigned int cols)
SNekMat SNekMat void SubtractEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
SNekMat NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_SINGLE_MATRIX(AddEqualNegatedLhs, NEKTAR_ALL_MATRIX_TYPES,(1,(void)),(1,(DNekMat &)),(0,())) NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_SINGLE_MATRIX(AddEqualNegatedLhs
void AddEqualNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
SNekMat void AddEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
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)
void NekMultiplyFullMatrixFullMatrix(NekMatrix< ResultType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
NEKTAR_ALL_MATRIX_TYPES_SINGLE
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)
SNekMat const NekSingle &void NekMultiplyDefaultImpl(NekMatrix< ResultType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
const NekSingle void MultiplyEqual(NekMatrix< LhsDataType, StandardMatrixTag > &lhs, typename boost::call_traits< LhsDataType >::const_reference rhs)
void SubtractNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
SNekMat NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES(AddNegatedLhs, NEKTAR_ALL_MATRIX_TYPES, NEKTAR_ALL_MATRIX_TYPES,(1,(void)),(1,(DNekMat &)),(0,())) NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES(AddNegatedLhs
SNekMat SNekMat void Add(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)