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())
186 for (
const std::initializer_list<Type>& lst : lstLst)
188 if (
label(lst.size()) != nCols_)
191 <<
"Number of columns in row " << rowi
192 <<
" is not equal to " << nCols_
196 for (
const Type&
v : lst)
206 template<
class Form,
class Type>
218 for (
label i=0; i<mn; i++)
226 template<
class Form,
class Type>
227 template<
class Form2>
239 for (
label i=0; i<mn; i++)
247 template<
class Form,
class Type>
248 template<
class MatrixType>
259 for (
label i=0; i<mRows_; i++)
261 for (
label j=0; j<nCols_; j++)
263 (*this)(i,j) = Mb(i,j);
269 template<
class Form,
class Type>
270 template<
class MatrixType>
281 for (
label i=0; i<mRows_; i++)
283 for (
label j=0; j<nCols_; j++)
285 (*this)(i,j) = Mb(i,j);
291 template<
class Form,
class Type>
292 template<
class MSForm, Foam::direction Mrows, Foam::direction Ncols>
303 for (
label i=0; i<mRows_; i++)
307 (*this)(i,j) = Ms(i,j);
315 template<
class Form,
class Type>
327 template<
class Form,
class Type>
341 template<
class Form,
class Type>
357 template<
class Form,
class Type>
365 for (
label i=0; i<minM; i++)
367 for (
label j=0; j<minN; j++)
369 newMatrix(i, j) = (*this)(i, j);
377 template<
class Form,
class Type>
383 for (
label i=0; i<m(); i++)
385 for (
label j=0; j<
n(); j++)
397 template<
class Form,
class Type>
403 <<
"Attempted assignment to self"
407 if (mRows_ !=
M.mRows_ || nCols_ !=
M.nCols_)
417 const label mn = size();
418 for (
label i=0; i<mn; i++)
426 template<
class Form,
class Type>
427 template<
class MatrixType>
433 for (
label i=0; i<mRows_; i++)
435 for (
label j=0; j<nCols_; j++)
437 (*this)(i,j) = Mb(i,j);
443 template<
class Form,
class Type>
444 template<
class MatrixType>
450 for (
label i=0; i<mRows_; i++)
452 for (
label j=0; j<nCols_; j++)
454 (*this)(i,j) = Mb(i,j);
460 template<
class Form,
class Type>
465 const label mn = size();
466 for (
label i=0; i<mn; i++)
474 template<
class Form,
class Type>
479 const label mn = size();
480 for (
label i=0; i<mn; i++)
490 template<
class Form,
class Type>
493 const label mn =
M.size();
498 const Type* Mv =
M.v();
500 for (
label i=1; i<mn; i++)
502 if (Mv[i] > Mv[curMaxI])
522 template<
class Form,
class Type>
525 const label mn =
M.size();
530 const Type* Mv =
M.v();
532 for (
label i=1; i<mn; i++)
534 if (Mv[i] < Mv[curMinI])
556 template<
class Form,
class Type>
559 Form nM(
M.m(),
M.n());
564 const Type* Mv =
M.v();
566 const label mn =
M.size();
567 for (
label i=0; i<mn; i++)
577 template<
class Form,
class Type>
583 <<
"Attempt to add matrices with different numbers of rows: "
584 <<
A.m() <<
", " <<
B.m()
591 <<
"Attempt to add matrices with different numbers of columns: "
592 <<
A.n() <<
", " <<
B.n()
596 Form AB(
A.m(),
A.n());
599 const Type* Av =
A.v();
600 const Type* Bv =
B.v();
602 const label mn =
A.size();
603 for (
label i=0; i<mn; i++)
605 ABv[i] = Av[i] + Bv[i];
612 template<
class Form,
class Type>
618 <<
"Attempt to add matrices with different numbers of rows: "
619 <<
A.m() <<
", " <<
B.m()
626 <<
"Attempt to add matrices with different numbers of columns: "
627 <<
A.n() <<
", " <<
B.n()
631 Form AB(
A.m(),
A.n());
634 const Type* Av =
A.v();
635 const Type* Bv =
B.v();
637 const label mn =
A.size();
638 for (
label i=0; i<mn; i++)
640 ABv[i] = Av[i] - Bv[i];
647 template<
class Form,
class Type>
650 Form sM(
M.m(),
M.n());
655 const Type* Mv =
M.v();
657 const label mn =
M.size();
658 for (
label i=0; i<mn; i++)
668 template<
class Form,
class Type>
671 Form sM(
M.m(),
M.n());
676 const Type* Mv =
M.v();
678 const label mn =
M.size();
679 for (
label i=0; i<mn; i++)
689 template<
class Form,
class Type>
692 Form sM(
M.m(),
M.n());
697 const Type* Mv =
M.v();
699 const label mn =
M.size();
700 for (
label i=0; i<mn; i++)
710 template<
class Form1,
class Form2,
class Type>
714 const Matrix<Form1, Type>&
A,
715 const Matrix<Form2, Type>&
B
721 <<
"Attempt to multiply incompatible matrices:" <<
nl
722 <<
"Matrix A : " <<
A.m() <<
" x " <<
A.n() <<
nl
723 <<
"Matrix B : " <<
B.m() <<
" x " <<
B.n() <<
nl
724 <<
"In order to multiply matrices, columns of A must equal "
736 for (
label i=0; i<AB.m(); i++)
738 for (
label j=0; j<AB.n(); j++)
742 AB(i, j) +=
A(i,
k)*
B(
k, j);
751 template<
class Form,
class Type>
754 const Matrix<Form, Type>&
M,
761 <<
"Attempt to multiply incompatible matrix and field:" <<
nl
762 <<
"Matrix : " <<
M.m() <<
" x " <<
M.n() <<
nl
763 <<
"Field : " <<
f.
size() <<
" rows" <<
nl
764 <<
"In order to multiply a matrix M and field f, "
765 "columns of M must equal rows of f"
769 tmp<Field<Type>> tMf(
new Field<Type>(
M.m(),
Zero));
770 Field<Type>& Mf = tMf.ref();
772 for (
label i=0; i<
M.m(); i++)
774 for (
label j=0; j<
M.n(); j++)
776 Mf[i] +=
M(i, j)*
f[j];
void size(const label)
Override size to be inconsistent with allocated storage.
A templated block of an (m x n) matrix of type <MatrixType>.
label n() const
Return the number of columns in the block.
label m() const
Return the number of rows in the block.
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)
const Type * v() const
Return element vector of the constant Matrix.
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)
tmp< DimensionedField< Type, GeoMesh, Field > > operator/(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< scalar, GeoMesh, PrimitiveField2 > &df2)
tmp< DimensionedField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, Field > > operator+(const DimensionedField< Type1, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type2, GeoMesh, PrimitiveField2 > &df2)
tmp< DimensionedField< Type, GeoMesh, Field > > operator*(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< scalar, GeoMesh, PrimitiveField2 > &df2)
labelList first(const UList< labelPair > &p)
tmp< DimensionedField< Type, GeoMesh, Field > > operator-(const DimensionedField< Type, GeoMesh, PrimitiveField > &df1)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.