Go to the documentation of this file.
65 template<
class Form,
class Type>
class Matrix;
74 template<
class Form,
class Type>
83 Type* __restrict__ v_;
89 inline void doAlloc();
92 template<
class ListType>
96 template<
class ListType>
130 Matrix(
const label
m,
const label
n);
138 Matrix(
const label
m,
const label
n,
const Type& val);
158 template<
class Form2>
162 template<
class MatrixType>
166 template<
class MatrixType>
185 inline label
m() const noexcept;
188 inline label
n() const noexcept;
191 inline label
size() const;
197 inline
bool empty() const noexcept;
201 inline const Type*
cdata() const noexcept;
205 inline Type*
data() noexcept;
209 inline const Type*
rowData(const label irow) const;
213 inline Type*
rowData(const label irow);
217 inline const Type&
at(const label idx) const;
221 inline Type&
at(const label idx);
232 const label colIndex,
233 const label rowIndex = 0,
244 const label rowIndex,
245 const label colIndex = 0,
253 const label rowIndex,
254 const label colIndex,
263 const label rowIndex,
272 const label colIndex,
273 const label rowIndex = 0,
280 const label rowIndex,
281 const label colIndex = 0,
288 const label rowIndex,
289 const label colIndex,
298 const label rowIndex,
305 inline
void checki(const label irow) const;
308 inline
void checkj(const label jcol) const;
333 void resize(const label
m, const label
n);
336 inline
void setSize(const label
m, const label
n);
342 void round(const scalar tol = SMALL);
380 scalar
columnNorm(const label colIndex, const
bool noSqrt=false) const;
384 scalar
norm(const
bool noSqrt=false) const;
391 inline const Type* operator[](const label irow) const;
395 inline Type* operator[](const label irow);
399 inline const Type& operator()(const label irow, const label jcol) const;
403 inline Type& operator()(const label irow, const label jcol);
406 void operator=(const
Matrix<Form, Type>& mat);
409 void operator=(
Matrix<Form, Type>&& mat);
412 template<class MatrixType>
416 template<class MatrixType>
423 void operator=(const Type& val);
426 void operator+=(const
Matrix<Form, Type>& other);
429 void operator-=(const
Matrix<Form, Type>& other);
432 void operator+=(const Type&
s);
435 void operator-=(const Type&
s);
438 void operator*=(const Type&
s);
441 void operator/=(const Type&
s);
482 inline label
mRows() const noexcept
488 inline label
nRows() const noexcept
494 inline label
nCols() const noexcept
503 const Type*
v()
const
573 void col(
const label
m,
const label rowStart)
const =
delete;
577 void col(
const label
m,
const label rowStart) =
delete;
584 template<
class Form,
class Type>
585 Istream&
operator>>(Istream& is, Matrix<Form, Type>& mat);
589 template<
class Form,
class Type>
590 Ostream&
operator<<(Ostream& os,
const Matrix<Form, Type>& mat);
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const typedef Type * const_iterator
Random access iterator for traversing a Matrix.
A class for managing temporary objects.
label n() const noexcept
The number of columns.
autoPtr< mType > clone() const
Clone.
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
label mRows() const noexcept
The number of rows - same as m()
void checkj(const label jcol) const
Check index j is within valid range [0, n)
labelPair sizes() const
Return row/column sizes.
Istream & operator>>(Istream &, directionInfo &)
Matrix< Form, Type > mType
Matrix type.
Type cmptType
Component type.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
label nCols() const noexcept
The number of columns - same as n()
void transfer(Matrix< Form, Type > &mat)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
const_iterator cend() const
Return const_iterator to end traversing a constant Matrix.
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Generic templated field type.
const Type & at(const label idx) const
Linear addressing const element access.
A templated block of an (m x n) matrix of type <MatrixType>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row's subset of Matrix.
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero)
ConstMatrixBlock< mType > subMatrix(const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
Return const sub-block of Matrix.
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
void clear()
Clear Matrix, i.e. set sizes to zero.
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Type * iterator
Random access iterator for traversing a Matrix.
label nRows() const noexcept
The number of rows - same as m()
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn()
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
label size() const
The number of elements in Matrix (m*n)
void swap(Matrix< Form, Type > &mat)
Swap contents.
Form T() const
Return (conjugate) transpose of Matrix.
iterator begin()
Return an iterator to begin traversing a Matrix.
iterator end()
Return an iterator to end traversing a Matrix.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Type trace() const
Return the trace.
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
label m() const noexcept
The number of rows.
void checki(const label irow) const
Check index i is within valid range [0, m)
void checkSize() const
Check that dimensions are positive, non-zero.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
const_iterator cbegin() const
Return const_iterator to begin traversing a constant Matrix.
const Type * cdata() const noexcept
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of Matrix.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
Database for solution data, solver performance and other reduced data.
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...