31 template<
class Form,
class Type>
36 v_ =
new Type[size()];
43 template<
class Form,
class Type>
50 if (mRows_ < 0 || nCols_ < 0)
53 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
61 template<
class Form,
class Type>
68 if (mRows_ < 0 || nCols_ < 0)
71 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
80 for (
label i=0; i<mn; i++)
88 template<
class Form,
class Type>
95 if (mRows_ < 0 || nCols_ < 0)
98 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
107 for (
label i=0; i<mn; i++)
115 template<
class Form,
class Type>
116 template<
class InputIterator>
129 if (mRows_ < 0 || nCols_ < 0)
132 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
136 if (std::distance(
first, last) != mRows_*nCols_)
139 <<
"Number of values provided " << std::distance(
first, last)
140 <<
" is not the same as the number of matrix elements "
150 InputIterator iter =
first;
151 for (
label i=0; i<mn; i++)
160 template<
class Form,
class Type>
165 std::initializer_list<Type> lst
168 Matrix(m,
n, lst.begin(), lst.end())
172 template<
class Form,
class Type>
175 std::initializer_list<std::initializer_list<Type>> lstLst
178 mRows_(lstLst.size()),
179 nCols_(lstLst.begin()->size())
187 typename std::initializer_list<std::initializer_list<Type>>,
192 if (
label(rowIter->size()) != nCols_)
195 <<
"Number of columns in row " << rowi
196 <<
" is not equal to " << nCols_
202 typename std::initializer_list<Type>,
215 template<
class Form,
class Type>
227 for (
label i=0; i<mn; i++)
235 template<
class Form,
class Type>
236 template<
class Form2>
248 for (
label i=0; i<mn; i++)
256 template<
class Form,
class Type>
257 template<
class MatrixType>
268 for (
label i=0; i<mRows_; i++)
270 for (
label j=0; j<nCols_; j++)
272 (*this)(i,j) = Mb(i,j);
278 template<
class Form,
class Type>
279 template<
class MatrixType>
290 for (
label i=0; i<mRows_; i++)
292 for (
label j=0; j<nCols_; j++)
294 (*this)(i,j) = Mb(i,j);
300 template<
class Form,
class Type>
301 template<
class MSForm, Foam::direction Mrows, Foam::direction Ncols>
312 for (
label i=0; i<mRows_; i++)
314 for (
label j=0; j<nCols_; j++)
316 (*this)(i,j) = Ms(i,j);
324 template<
class Form,
class Type>
336 template<
class Form,
class Type>
350 template<
class Form,
class Type>
366 template<
class Form,
class Type>
374 for (
label i=0; i<minM; i++)
376 for (
label j=0; j<minN; j++)
378 newMatrix(i, j) = (*this)(i, j);
386 template<
class Form,
class Type>
392 for (
label i=0; i<m(); i++)
394 for (
label j=0; j<
n(); j++)
406 template<
class Form,
class Type>
412 <<
"Attempted assignment to self"
416 if (mRows_ !=
M.mRows_ || nCols_ !=
M.nCols_)
426 const label mn = size();
427 for (
label i=0; i<mn; i++)
435 template<
class Form,
class Type>
436 template<
class MatrixType>
442 for (
label i=0; i<mRows_; i++)
444 for (
label j=0; j<nCols_; j++)
446 (*this)(i,j) = Mb(i,j);
452 template<
class Form,
class Type>
453 template<
class MatrixType>
459 for (
label i=0; i<mRows_; i++)
461 for (
label j=0; j<nCols_; j++)
463 (*this)(i,j) = Mb(i,j);
469 template<
class Form,
class Type>
474 const label mn = size();
475 for (
label i=0; i<mn; i++)
483 template<
class Form,
class Type>
488 const label mn = size();
489 for (
label i=0; i<mn; i++)
499 template<
class Form,
class Type>
502 const label mn =
M.size();
507 const Type* Mv =
M.v();
509 for (
label i=1; i<mn; i++)
511 if (Mv[i] > Mv[curMaxI])
531 template<
class Form,
class Type>
534 const label mn =
M.size();
539 const Type* Mv =
M.v();
541 for (
label i=1; i<mn; i++)
543 if (Mv[i] < Mv[curMinI])
565 template<
class Form,
class Type>
568 Form nM(
M.m(),
M.n());
573 const Type* Mv =
M.v();
575 const label mn =
M.size();
576 for (
label i=0; i<mn; i++)
586 template<
class Form,
class Type>
592 <<
"Attempt to add matrices with different numbers of rows: "
593 <<
A.m() <<
", " <<
B.m()
600 <<
"Attempt to add matrices with different numbers of columns: "
601 <<
A.n() <<
", " <<
B.n()
605 Form AB(
A.m(),
A.n());
608 const Type* Av =
A.v();
609 const Type* Bv =
B.v();
611 const label mn =
A.size();
612 for (
label i=0; i<mn; i++)
614 ABv[i] = Av[i] + Bv[i];
621 template<
class Form,
class Type>
627 <<
"Attempt to add matrices with different numbers of rows: "
628 <<
A.m() <<
", " <<
B.m()
635 <<
"Attempt to add matrices with different numbers of columns: "
636 <<
A.n() <<
", " <<
B.n()
640 Form AB(
A.m(),
A.n());
643 const Type* Av =
A.v();
644 const Type* Bv =
B.v();
646 const label mn =
A.size();
647 for (
label i=0; i<mn; i++)
649 ABv[i] = Av[i] - Bv[i];
656 template<
class Form,
class Type>
659 Form sM(
M.m(),
M.n());
664 const Type* Mv =
M.v();
666 const label mn =
M.size();
667 for (
label i=0; i<mn; i++)
677 template<
class Form,
class Type>
680 Form sM(
M.m(),
M.n());
685 const Type* Mv =
M.v();
687 const label mn =
M.size();
688 for (
label i=0; i<mn; i++)
698 template<
class Form,
class Type>
701 Form sM(
M.m(),
M.n());
706 const Type* Mv =
M.v();
708 const label mn =
M.size();
709 for (
label i=0; i<mn; i++)
719 template<
class Form1,
class Form2,
class Type>
723 const Matrix<Form1, Type>&
A,
724 const Matrix<Form2, Type>&
B
730 <<
"Attempt to multiply incompatible matrices:" <<
nl
731 <<
"Matrix A : " <<
A.m() <<
" x " <<
A.n() <<
nl
732 <<
"Matrix B : " <<
B.m() <<
" x " <<
B.n() <<
nl
733 <<
"In order to multiply matrices, columns of A must equal "
745 for (
label i=0; i<AB.m(); i++)
747 for (
label j=0; j<AB.n(); j++)
751 AB(i, j) +=
A(i,
k)*
B(
k, j);
760 template<
class Form,
class Type>
763 const Matrix<Form, Type>&
M,
770 <<
"Attempt to multiply incompatible matrix and field:" <<
nl
771 <<
"Matrix : " <<
M.m() <<
" x " <<
M.n() <<
nl
772 <<
"Field : " <<
f.
size() <<
" rows" <<
nl
773 <<
"In order to multiply a matrix M and field f, "
774 "columns of M must equal rows of f"
778 tmp<Field<Type>> tMf(
new Field<Type>(
M.m(),
Zero));
779 Field<Type>& Mf = tMf.ref();
781 for (
label i=0; i<
M.m(); i++)
783 for (
label j=0; j<
M.n(); j++)
785 Mf[i] +=
M(i, j)*
f[j];
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static const coefficient B("B", dimless, 18.678)
static const coefficient A("A", dimPressure, 611.21)
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)
labelList first(const UList< labelPair > &p)
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.