65 template<
class Form,
class Type>
class Matrix;
69 template<
class Form,
class Type>
72 template<
class Form,
class Type>
73 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
80 template<
class Form,
class Type>
89 Type* __restrict__ v_;
95 inline void doAlloc();
98 template<
class ListType>
102 template<
class ListType>
121 return NullObjectRef<Matrix<Form, Type>>();
140 Matrix(const label
m, const label
n);
148 Matrix(const label
m, const label
n, const Type& val);
168 template<class Form2>
172 template<class MatrixType>
176 template<class MatrixType>
201 label
m() const
noexcept {
return mRows_; }
207 label
n() const
noexcept {
return nCols_; }
213 inline label
size() const;
247 inline const Type*
rowData(const label irow) const;
251 inline Type*
rowData(const label irow);
255 inline const Type&
at(const label idx) const;
259 inline Type&
at(const label idx);
270 const label colIndex,
271 const label rowIndex = 0,
282 const label rowIndex,
283 const label colIndex = 0,
291 const label rowIndex,
292 const label colIndex,
301 const label rowIndex,
310 const label colIndex,
311 const label rowIndex = 0,
318 const label rowIndex,
319 const label colIndex = 0,
326 const label rowIndex,
327 const label colIndex,
336 const label rowIndex,
343 inline
void checki(const label irow) const;
346 inline
void checkj(const label jcol) const;
371 void resize(const label
m, const label
n);
377 inline
void setSize(const label
m, const label
n);
383 void round(const scalar tol = SMALL);
425 scalar
columnNorm(const label colIndex, const
bool noSqrt=false) const;
429 scalar
norm(const
bool noSqrt=false) const;
436 inline const Type* operator[](const label irow) const;
440 inline Type* operator[](const label irow);
444 inline const Type& operator()(const label irow, const label jcol) const;
448 inline Type& operator()(const label irow, const label jcol);
451 void operator=(const
Matrix<Form, Type>& mat);
454 void operator=(
Matrix<Form, Type>&& mat);
457 template<class MatrixType>
461 template<class MatrixType>
468 void operator=(const Type& val);
471 void operator+=(const
Matrix<Form, Type>& other);
474 void operator-=(const
Matrix<Form, Type>& other);
477 void operator+=(const Type&
s);
480 void operator-=(const Type&
s);
483 void operator*=(const Type&
s);
486 void operator/=(const Type&
s);
529 const Type*
v()
const 599 void col(
const label
m,
const label rowStart)
const =
delete;
603 void col(
const label
m,
const label rowStart) =
delete;
610 template<
class Form,
class Type>
611 Istream&
operator>>(Istream& is, Matrix<Form, Type>& mat)
620 template<
class Form,
class Type>
621 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat)
623 return mat.writeMatrix(
os, Detail::ListPolicy::short_length<Type>::value);
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of 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.
autoPtr< mType > clone() const
Clone.
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
Form T() const
Return conjugate transpose of Matrix.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
A templated block of an (m x n) matrix of type <MatrixType>.
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
List< Type > release()
Release storage management of Matrix contents by transferring management to a List.
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void transfer(Matrix< Form, Type > &mat)
Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix...
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero)
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
ConstMatrixBlock< mType > subMatrix(const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
Return const sub-block of Matrix.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
label nCols() const noexcept
The number of columns.
label n() const noexcept
The number of columns.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write Matrix, with line-breaks in ASCII when length exceeds shortLen.
label size() const
The number of elements in Matrix (m*n)
Type trace() const
Return the trace.
Generic templated field type.
const Type & at(const label idx) const
Linear addressing const element access.
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
Type * iterator
Random access iterator for traversing a Matrix.
label nRows() const noexcept
The number of rows.
labelPair sizes() const
Return row/column sizes.
Istream & operator>>(Istream &, directionInfo &)
iterator end() noexcept
Return an iterator to end traversing a Matrix.
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
void clear()
Clear Matrix, i.e. set sizes to zero.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const Type * cdata() const noexcept
Return const pointer to the first data element, which can also be used to address into Matrix content...
void checki(const label irow) const
Check index i is within valid range [0, m)
void swap(Matrix< Form, Type > &mat)
Swap contents.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Type cmptType
Component type.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous...
Pair< label > labelPair
A pair of labels.
OBJstream os(runTime.globalPath()/outputName)
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
label m() const noexcept
The number of rows.
const Type * const_iterator
Random access iterator for traversing a Matrix.
std::streamsize byteSize() const
Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous...
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
label mRows() const noexcept
The number of rows.
Matrix< Form, Type > mType
Matrix type.
static const Matrix< Form, Type > & null() noexcept
Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.
Form transpose() const
Return non-conjugate transpose of Matrix.
void checkj(const label jcol) const
Check index j is within valid range [0, n)
Matrix() noexcept
Default construct (empty matrix)
Type * data() noexcept
Return pointer to the first data element, which can also be used to address into Matrix contents...
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
void resize_nocopy(const label mrow, const label ncol)
Change Matrix dimensions without preserving existing content.
A class for managing temporary objects.
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))
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn()
ConstMatrixBlock< mType > block(const label rowIndex, const label colIndex) const
Access Field as a ConstMatrixBlock.
void checkSize() const
Check that dimensions are positive, non-zero.