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;
62 template<
typename DataType,
typename LhsDataType,
typename LhsMatrixType>
78 template<
typename RhsDataType,
typename RhsMatrixType,
typename ResultDataType>
80 const ResultDataType& lhs,
92 template<typename DataType, typename RhsDataType, typename RhsMatrixType>
93 NekMatrix<typename
NekMatrix<RhsDataType, RhsMatrixType>::NumberType, StandardMatrixTag>
95 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
106 template<typename LhsDataType>
108 typename
boost::call_traits<LhsDataType>::const_reference rhs)
111 for( iterator iter = lhs.begin(); iter != lhs.end(); ++iter)
121 template<
typename ResultType,
typename LhsDataType,
typename RhsDataType,
122 typename LhsMatrixType,
typename RhsMatrixType>
127 ASSERTL1(lhs.GetColumns() == rhs.GetRows(), std::string(
"A left side matrix with column count ") +
128 std::to_string(lhs.GetColumns()) +
129 std::string(
" and a right side matrix with row count ") +
130 std::to_string(rhs.GetRows()) + std::string(
" can't be multiplied."));
132 for(
unsigned int i = 0; i < result.GetRows(); ++i)
134 for(
unsigned int j = 0; j < result.GetColumns(); ++j)
136 ResultType t = ResultType(0);
139 for(
unsigned int k = 0; k < lhs.GetColumns(); ++k)
141 t += lhs(i,k)*rhs(k,j);
148 template<
typename ResultType,
typename LhsDataType,
typename RhsDataType,
149 typename LhsMatrixType,
typename RhsMatrixType>
157 template<
typename LhsDataType,
typename RhsDataType,
typename DataType,
158 typename LhsMatrixType,
typename RhsMatrixType>
163 ASSERTL1(lhs.GetColumns() == rhs.GetRows(), std::string(
"A left side matrix with column count ") +
164 std::to_string(lhs.GetColumns()) +
165 std::string(
" and a right side matrix with row count ") +
166 std::to_string(rhs.GetRows()) + std::string(
" can't be multiplied."));
168 result.
SetSize(lhs.GetRows(), rhs.GetColumns());
169 if( lhs.GetType() ==
eFULL && rhs.GetType() ==
eFULL)
182 (1, (
void)), (1, (
SNekMat&)), (0, ()))
184 template<typename DataType, typename RhsDataType, typename RhsMatrixType>
186 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
188 ASSERTL1(result.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
189 std::to_string(result.GetRows()) + std::string(
" and ") +
190 std::to_string(rhs.GetRows()) + std::string(
" can't be added."));
191 ASSERTL1(result.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
192 std::to_string(result.GetColumns()) + std::string(
" and ") +
193 std::to_string(rhs.GetColumns()) + std::string(
" can't be added."));
195 for(
unsigned int i = 0; i < rhs.GetRows(); ++i)
197 for(
unsigned int j = 0; j < rhs.GetColumns(); ++j)
199 result(i,j) += rhs(i,j);
205 template<
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
209 ASSERTL1(result.
GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
210 std::to_string(result.
GetRows()) + std::string(
" and ") +
211 std::to_string(rhs.GetRows()) + std::string(
" can't be added."));
212 ASSERTL1(result.
GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
213 std::to_string(result.
GetColumns()) + std::string(
" and ") +
214 std::to_string(rhs.GetColumns()) + std::string(
" can't be added."));
216 for(
unsigned int i = 0; i < rhs.GetRows(); ++i)
218 for(
unsigned int j = 0; j < rhs.GetColumns(); ++j)
220 result(i,j) = -result(i,j) + rhs(i,j);
234 template<typename DataType, typename LhsDataType, typename LhsMatrixType, typename RhsDataType, typename RhsMatrixType>
236 const
NekMatrix<LhsDataType, LhsMatrixType>& lhs,
237 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
239 ASSERTL1(lhs.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
240 std::to_string(lhs.GetRows()) + std::string(
" and ") +
241 std::to_string(rhs.GetRows()) + std::string(
" can't be added."));
242 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
243 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
244 std::to_string(rhs.GetColumns()) + std::string(
" can't be added."));
246 for(
unsigned int i = 0; i < lhs.GetRows(); ++i)
248 for(
unsigned int j = 0; j < lhs.GetColumns(); ++j)
250 result(i,j) = lhs(i,j) + rhs(i,j);
255 template<
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
typename RhsDataType,
typename RhsMatrixType>
260 ASSERTL1(lhs.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
261 std::to_string(lhs.GetRows()) + std::string(
" and ") +
262 std::to_string(rhs.GetRows()) + std::string(
" can't be added."));
263 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
264 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
265 std::to_string(rhs.GetColumns()) + std::string(
" can't be added."));
267 for(
unsigned int i = 0; i < lhs.GetRows(); ++i)
269 for(
unsigned int j = 0; j < lhs.GetColumns(); ++j)
271 result(i,j) = -lhs(i,j) + rhs(i,j);
279 (1, (
void)), (1, (
SNekMat&)), (0, ()))
283 (1, (
void)), (1, (
SNekMat&)), (0, ()))
286 template<typename LhsDataType, typename LhsMatrixType, typename RhsDataType, typename RhsMatrixType>
287 NekMatrix<typename
NekMatrix<LhsDataType, LhsMatrixType>::NumberType, StandardMatrixTag>
289 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
293 Add(result, lhs, rhs);
300 (1, (
SNekMat)), (0, ()), (0, ()))
302 template<typename DataType, typename LhsDataType, typename LhsMatrixType, typename RhsDataType, typename RhsMatrixType>
304 const
NekMatrix<LhsDataType, LhsMatrixType>& lhs,
305 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
307 ASSERTL1(lhs.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
308 std::to_string(lhs.GetRows()) + std::string(
" and ") +
309 std::to_string(rhs.GetRows()) + std::string(
" can't be subtracted."));
310 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
311 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
312 std::to_string(rhs.GetColumns()) + std::string(
" can't be subtracted."));
314 for(
unsigned int i = 0; i < lhs.GetRows(); ++i)
316 for(
unsigned int j = 0; j < lhs.GetColumns(); ++j)
318 result(i,j) = lhs(i,j) - rhs(i,j);
323 template<
typename DataType,
typename LhsDataType,
typename LhsMatrixType,
typename RhsDataType,
typename RhsMatrixType>
328 ASSERTL1(lhs.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
329 std::to_string(lhs.GetRows()) + std::string(
" and ") +
330 std::to_string(rhs.GetRows()) + std::string(
" can't be subtracted."));
331 ASSERTL1(lhs.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
332 std::to_string(lhs.GetColumns()) + std::string(
" and ") +
333 std::to_string(rhs.GetColumns()) + std::string(
" can't be subtracted."));
335 for(
unsigned int i = 0; i < lhs.GetRows(); ++i)
337 for(
unsigned int j = 0; j < lhs.GetColumns(); ++j)
339 result(i,j) = -lhs(i,j) - rhs(i,j);
347 (1, (
void)), (1, (
SNekMat&)), (0, ()))
355 template<typename DataType, typename RhsDataType, typename RhsMatrixType>
357 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
359 ASSERTL1(result.GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
360 std::to_string(result.GetRows()) + std::string(
" and ") +
361 std::to_string(rhs.GetRows()) + std::string(
" can't be subtracted."));
362 ASSERTL1(result.GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
363 std::to_string(result.GetColumns()) + std::string(
" and ") +
364 std::to_string(rhs.GetColumns()) + std::string(
" can't be subtracted."));
366 for(
unsigned int i = 0; i < rhs.GetRows(); ++i)
368 for(
unsigned int j = 0; j < rhs.GetColumns(); ++j)
370 result(i,j) -= rhs(i,j);
375 template<
typename DataType,
typename RhsDataType,
typename RhsMatrixType>
379 ASSERTL1(result.
GetRows() == rhs.GetRows(), std::string(
"Matrices with different row counts ") +
380 std::to_string(result.
GetRows()) + std::string(
" and ") +
381 std::to_string(rhs.GetRows()) + std::string(
" can't be subtracted."));
382 ASSERTL1(result.
GetColumns() == rhs.GetColumns(), std::string(
"Matrices with different column counts ") +
383 std::to_string(result.
GetColumns()) + std::string(
" and ") +
384 std::to_string(rhs.GetColumns()) + std::string(
" can't be subtracted."));
386 for(
unsigned int i = 0; i < rhs.GetRows(); ++i)
388 for(
unsigned int j = 0; j < rhs.GetColumns(); ++j)
390 result(i,j) = -result(i,j) - rhs(i,j);
401 (1, (
void)), (1, (
SNekMat&)), (0, ()))
403 template<typename LhsDataType, typename LhsMatrixType, typename RhsDataType, typename RhsMatrixType>
404 NekMatrix<typename
NekMatrix<LhsDataType, LhsMatrixType>::NumberType, StandardMatrixTag>
406 const
NekMatrix<RhsDataType, RhsMatrixType>& rhs)
417 (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)
The above copyright notice and this permission notice shall be included.
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
SNekMat const NekSingle &void NekMultiplyDefaultImpl(NekMatrix< ResultType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &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)
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)