30 template<
class Form,
class Type>
35 v_ =
new Type[size()];
42 template<
class Form,
class Type>
49 if (mRows_ < 0 || nCols_ < 0)
52 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
60 template<
class Form,
class Type>
67 if (mRows_ < 0 || nCols_ < 0)
70 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
79 for (
label i=0; i<mn; i++)
87 template<
class Form,
class Type>
94 if (mRows_ < 0 || nCols_ < 0)
97 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
106 for (
label i=0; i<mn; i++)
114 template<
class Form,
class Type>
126 for (
label i=0; i<mn; i++)
134 template<
class Form,
class Type>
135 template<
class Form2>
146 const label mn = size();
155 template<
class Form,
class Type>
156 template<
class MatrixType>
167 for (
label i=0; i<mRows_; i++)
169 for (
label j=0; j<nCols_; j++)
171 (*this)(i,j) = Mb(i,j);
177 template<
class Form,
class Type>
178 template<
class MatrixType>
189 for (
label i=0; i<mRows_; i++)
191 for (
label j=0; j<nCols_; j++)
193 (*this)(i,j) = Mb(i,j);
201 template<
class Form,
class Type>
213 template<
class Form,
class Type>
227 template<
class Form,
class Type>
243 template<
class Form,
class Type>
251 for (
label i=0; i<minM; i++)
253 for (
label j=0; j<minN; j++)
255 newMatrix(i, j) = (*this)(i, j);
263 template<
class Form,
class Type>
269 for (
label i=0; i<m(); i++)
271 for (
label j=0; j<
n(); j++)
283 template<
class Form,
class Type>
289 <<
"Attempted assignment to self"
293 if (mRows_ !=
M.mRows_ || nCols_ !=
M.nCols_)
303 const label mn = size();
304 for (
label i=0; i<mn; i++)
312 template<
class Form,
class Type>
313 template<
class MatrixType>
319 for (
label i=0; i<mRows_; i++)
321 for (
label j=0; j<nCols_; j++)
323 (*this)(i,j) = Mb(i,j);
329 template<
class Form,
class Type>
330 template<
class MatrixType>
336 for (
label i=0; i<mRows_; i++)
338 for (
label j=0; j<nCols_; j++)
340 (*this)(i,j) = Mb(i,j);
346 template<
class Form,
class Type>
351 const label mn = size();
352 for (
label i=0; i<mn; i++)
360 template<
class Form,
class Type>
365 const label mn = size();
366 for (
label i=0; i<mn; i++)
376 template<
class Form,
class Type>
379 const label mn =
M.size();
384 const Type* Mv =
M.v();
386 for (
label i=1; i<mn; i++)
388 if (Mv[i] > Mv[curMaxI])
408 template<
class Form,
class Type>
411 const label mn =
M.size();
416 const Type* Mv =
M.v();
418 for (
label i=1; i<mn; i++)
420 if (Mv[i] < Mv[curMinI])
442 template<
class Form,
class Type>
445 Form nM(
M.m(),
M.n());
450 const Type* Mv =
M.v();
452 const label mn =
M.size();
453 for (
label i=0; i<mn; i++)
463 template<
class Form,
class Type>
469 <<
"Attempt to add matrices with different numbers of rows: "
470 <<
A.m() <<
", " <<
B.m()
477 <<
"Attempt to add matrices with different numbers of columns: "
478 <<
A.n() <<
", " <<
B.n()
482 Form AB(
A.m(),
A.n());
485 const Type* Av =
A.v();
486 const Type* Bv =
B.v();
488 const label mn =
A.size();
489 for (
label i=0; i<mn; i++)
491 ABv[i] = Av[i] + Bv[i];
498 template<
class Form,
class Type>
504 <<
"Attempt to add matrices with different numbers of rows: "
505 <<
A.m() <<
", " <<
B.m()
512 <<
"Attempt to add matrices with different numbers of columns: "
513 <<
A.n() <<
", " <<
B.n()
517 Form AB(
A.m(),
A.n());
520 const Type* Av =
A.v();
521 const Type* Bv =
B.v();
523 const label mn =
A.size();
524 for (
label i=0; i<mn; i++)
526 ABv[i] = Av[i] - Bv[i];
533 template<
class Form,
class Type>
536 Form sM(
M.m(),
M.n());
541 const Type* Mv =
M.v();
543 const label mn =
M.size();
544 for (
label i=0; i<mn; i++)
554 template<
class Form,
class Type>
557 Form sM(
M.m(),
M.n());
562 const Type* Mv =
M.v();
564 const label mn =
M.size();
565 for (
label i=0; i<mn; i++)
575 template<
class Form,
class Type>
578 Form sM(
M.m(),
M.n());
583 const Type* Mv =
M.v();
585 const label mn =
M.size();
586 for (
label i=0; i<mn; i++)
596 template<
class Form1,
class Form2,
class Type>
600 const Matrix<Form1, Type>&
A,
601 const Matrix<Form2, Type>&
B
607 <<
"Attempt to multiply incompatible matrices:" <<
nl
608 <<
"Matrix A : " <<
A.m() <<
" x " <<
A.n() <<
nl
609 <<
"Matrix B : " <<
B.m() <<
" x " <<
B.n() <<
nl
610 <<
"In order to multiply matrices, columns of A must equal "
622 for (
label i=0; i<AB.m(); i++)
624 for (
label j=0; j<AB.n(); j++)
628 AB(i, j) +=
A(i,
k)*
B(
k, j);
637 template<
class Form,
class Type>
640 const Matrix<Form, Type>&
M,
647 <<
"Attempt to multiply incompatible matrix and field:" <<
nl
648 <<
"Matrix : " <<
M.m() <<
" x " <<
M.n() <<
nl
649 <<
"Field : " <<
f.
size() <<
" rows" <<
nl
650 <<
"In order to multiply a matrix M and field f, "
651 "columns of M must equal rows of f"
655 tmp<Field<Type>> tMf(
new Field<Type>(
M.m(),
Zero));
656 Field<Type>& Mf = tMf.ref();
658 for (
label i=0; i<
M.m(); i++)
660 for (
label j=0; j<
M.n(); j++)
662 Mf[i] +=
M(i, j)*
f[j];
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
void size(const label)
Override size to be inconsistent with allocated storage.
A templated block of an (m x n) matrix of type <MatrixType>.
A templated (m x n) matrix of objects of <T>.
Matrix()
Null constructor.
label size() const
Return the number of elements in matrix (m*n)
void operator=(const mType &)
Assignment operator. Takes linear time.
void transfer(mType &)
Transfer the contents of the argument Matrix into this Matrix.
Form T() const
Return the transpose of the matrix.
void setSize(const label m, const label n)
Resize the matrix preserving the elements.
void clear()
Clear the Matrix, i.e. set sizes to zero.
A class for managing temporary objects.
Abstract template class to provide the form resulting from.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManip< error > abort(error &err)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator/(const fvMatrix< Type > &, const volScalarField::Internal &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.