65template<
class Form,
class Type>
class Matrix;
69template<
class Form,
class Type>
72template<
class Form,
class Type>
80template<
class Form,
class Type>
89 Type* __restrict__ v_;
95 inline void doAlloc();
98 template<
class ListType>
102 template<
class ListType>
145 Matrix(const label
m, const label
n);
153 Matrix(const label
m, const label
n, const Type& val);
173 template<class Form2>
177 template<class MatrixType>
181 template<class MatrixType>
206 label
m() const
noexcept {
return mRows_; }
212 label
n() const
noexcept {
return nCols_; }
252 inline const Type*
rowData(const label irow) const;
260 inline const Type&
at(const label idx) const;
264 inline Type&
at(const label idx);
275 const label colIndex,
276 const label rowIndex = 0,
287 const label rowIndex,
288 const label colIndex = 0,
296 const label rowIndex,
297 const label colIndex,
306 const label rowIndex,
315 const label colIndex,
316 const label rowIndex = 0,
323 const label rowIndex,
324 const label colIndex = 0,
331 const label rowIndex,
332 const label colIndex,
341 const label rowIndex,
348 inline
void checki(const label irow) const;
351 inline
void checkj(const label jcol) const;
376 void resize(const label
m, const label
n);
382 inline
void setSize(const label
m, const label
n);
388 void round(const scalar tol = SMALL);
430 scalar
columnNorm(const label colIndex, const
bool noSqrt=false) const;
434 scalar
norm(const
bool noSqrt=false) const;
441 inline const Type* operator[](const label irow) const;
445 inline Type* operator[](const label irow);
449 inline const Type& operator()(const label irow, const label jcol) const;
453 inline Type& operator()(const label irow, const label jcol);
456 void operator=(const
Matrix<Form, Type>& mat);
459 void operator=(
Matrix<Form, Type>&& mat);
462 template<class MatrixType>
466 template<class MatrixType>
473 void operator=(const Type& val);
476 void operator+=(const
Matrix<Form, Type>& other);
479 void operator-=(const
Matrix<Form, Type>& other);
482 void operator+=(const Type&
s);
485 void operator-=(const Type&
s);
488 void operator*=(const Type&
s);
491 void operator/=(const Type&
s);
534 const Type*
v()
const
604 void col(
const label
m,
const label rowStart)
const =
delete;
608 void col(
const label
m,
const label rowStart) =
delete;
615template<
class Form,
class Type>
625template<
class Form,
class Type>
628 return mat.writeMatrix(
os, Foam::ListPolicy::short_length<Type>::value);
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A templated block of an (m x n) matrix of type <MatrixType>.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
const Type * const_iterator
Random access iterator for traversing a Matrix.
label size_type
The type to represent the size of a Matrix.
Type * data() noexcept
Return pointer to the first data element, which can also be used to address into Matrix contents.
constexpr Matrix() noexcept
Default construct (empty matrix).
static const Matrix< Form, Type > & null() noexcept
Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn().
const Type * cdata() const noexcept
Return const pointer to the first data element, which can also be used to address into Matrix content...
Type * iterator
Random access iterator for traversing a Matrix.
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row's subset of Matrix.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data.
Type value_type
The value type the Matrix contains.
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
List< Type > release()
Release storage management of Matrix contents by transferring management to a List.
Type cmptType
The value type the Matrix contains.
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero).
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write Matrix, with line-breaks in ASCII when length exceeds shortLen.
autoPtr< mType > clone() const
Clone.
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
void col(const label m, const label rowStart) const =delete
Deleted(2019-04) - use subColumn().
label m() const noexcept
The number of rows.
void transfer(Matrix< Form, Type > &mat)
Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix.
labelPair sizes() const noexcept
Return row/column sizes.
Form transpose() const
Return non-conjugate transpose of Matrix.
void checki(const label irow) const
Check index i is within valid range [0, m).
label mRows() const noexcept
The number of rows.
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe).
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
void checkSize() const
Check that dimensions are positive, non-zero.
Type trace() const
Return the trace.
ConstMatrixBlock< mType > subMatrix(const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
Return const sub-block of Matrix.
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
label size() const noexcept
The number of elements in Matrix (m*n).
Form T() const
Return conjugate transpose of Matrix.
label nCols() const noexcept
The number of columns.
void resize_nocopy(const label mrow, const label ncol)
Change Matrix dimensions without preserving existing content.
label n() const noexcept
The number of columns.
iterator end() noexcept
Return an iterator to end traversing a Matrix.
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
label nRows() const noexcept
The number of rows.
std::streamsize byteSize() const
Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous.
void swap(Matrix< Form, Type > &mat)
Swap contents.
bool uniform() const
True if all entries have identical values, and Matrix is non-empty.
ConstMatrixBlock< mType > block(const label rowIndex, const label colIndex) const
Access Field as a ConstMatrixBlock.
const Type & at(const label idx) const
Linear addressing const element access.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data.
void clear()
Clear Matrix, i.e. set sizes to zero.
void checkj(const label jcol) const
Check index j is within valid range [0, n).
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
void col(const label m, const label rowStart)=delete
Deleted(2019-04) - use subColumn().
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous...
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A).
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x).
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of Matrix.
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Matrix< Form, Type > mType
Matrix type.
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing temporary objects.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
OBJstream os(runTime.globalPath()/outputName)
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))
Pair< label > labelPair
A pair of labels.
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
#define FOAM_DEPRECATED_FOR(since, replacement)
Number of items before requiring line-breaks in the list output.