33template<
class Form,
class Type>
34inline void Foam::Matrix<Form, Type>::doAlloc()
36 const label len = size();
41 this->v_ = ListPolicy::allocate<Type>(len);
49template<
class Form,
class Type>
58template<
class Form,
class Type>
61 Matrix<Form, Type>(dims.first(), dims.second())
65template<
class Form,
class Type>
72template<
class Form,
class Type>
75 Matrix<Form, Type>(dims.first(), dims.second(), val)
79template<
class Form,
class Type>
89template<
class Form,
class Type>
92 return (mRows_ * nCols_);
96template<
class Form,
class Type>
103template<
class Form,
class Type>
106 return !mRows_ || !nCols_;
110template<
class Form,
class Type>
113 if (!mRows_ || !nCols_)
116 <<
"Attempt to access element from empty matrix"
119 if (i < 0 || mRows_ <= i)
122 <<
"Index " << i <<
" out of range 0 ... " << mRows_-1
128template<
class Form,
class Type>
131 if (!mRows_ || !nCols_)
134 <<
"Attempt to access element from empty matrix"
137 if (j < 0 || nCols_ <= j)
140 <<
"index " << j <<
" out of range 0 ... " << nCols_-1
146template<
class Form,
class Type>
149 if (mRows_ < 0 || nCols_ < 0)
152 <<
"Incorrect size (" << mRows_ <<
", " << nCols_ <<
')' <<
nl
159template<
class Form,
class Type>
162 const label len = size();
170 for (label idx = 1; idx < len; ++idx)
172 if (v_[0] != v_[idx])
182template<
class Form,
class Type>
189template<
class Form,
class Type>
196template<
class Form,
class Type>
199 return reinterpret_cast<const char*
>(v_);
203template<
class Form,
class Type>
206 return reinterpret_cast<char*
>(v_);
210template<
class Form,
class Type>
213 return std::streamsize(mRows_*nCols_)*
sizeof(Type);
217template<
class Form,
class Type>
223 return (v_ + irow*nCols_);
227template<
class Form,
class Type>
233 return (v_ + irow*nCols_);
237template<
class Form,
class Type>
241 if (idx < 0 || this->
size() <= idx)
244 <<
"index " << idx <<
" out of range 0 ... " << this->
size()
252template<
class Form,
class Type>
256 if (idx < 0 || this->size() <= idx)
259 <<
"index " << idx <<
" out of range 0 ... " << this->size()
267template<
class Form,
class Type>
271 const label colIndex,
272 const label rowIndex,
278 len = mRows_ - rowIndex;
292template<
class Form,
class Type>
296 const label rowIndex,
297 const label colIndex,
303 len = nCols_ - colIndex;
317template<
class Form,
class Type>
321 const label rowIndex,
322 const label colIndex,
327 if (szRows < 0) szRows = mRows_ - rowIndex;
328 if (szCols < 0) szCols = nCols_ - colIndex;
341template<
class Form,
class Type>
342template<
class VectorSpace>
346 const label rowIndex,
361template<
class Form,
class Type>
365 const label colIndex,
366 const label rowIndex,
372 len = mRows_ - rowIndex;
386template<
class Form,
class Type>
390 const label rowIndex,
391 const label colIndex,
397 len = nCols_ - colIndex;
411template<
class Form,
class Type>
415 const label rowIndex,
416 const label colIndex,
421 if (szRows < 0) szRows = mRows_ - rowIndex;
422 if (szCols < 0) szCols = nCols_ - colIndex;
435template<
class Form,
class Type>
436template<
class VectorSpace>
440 const label rowIndex,
455template<
class Form,
class Type>
462template<
class Form,
class Type>
470template<
class Form,
class Type>
480template<
class Form,
class Type>
487 return this->AmulImpl(
x);
491template<
class Form,
class Type>
501template<
class Form,
class Type>
508 return this->TmulImpl(
x);
514template<
class Form,
class Type>
522template<
class Form,
class Type>
526 return v_ + (mRows_ * nCols_);
530template<
class Form,
class Type>
538template<
class Form,
class Type>
542 return v_ + (mRows_ * nCols_);
546template<
class Form,
class Type>
554template<
class Form,
class Type>
558 return v_ + (mRows_ * nCols_);
564template<
class Form,
class Type>
575 return v_[irow*nCols_ + jcol];
579template<
class Form,
class Type>
590 return v_[irow*nCols_ + jcol];
594template<
class Form,
class Type>
600 return v_ + irow*nCols_;
604template<
class Form,
class Type>
610 return v_ + irow*nCols_;
622template<
class Form,
class Type>
634template<
class Form,
class Type,
class Addr>
646template<
class Form,
class Type>
658template<
class Form,
class Type,
class Addr>
659inline tmp<Field<Type>>
operator*
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
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.
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).
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.
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
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.
autoPtr< mType > clone() const
Clone.
label m() const noexcept
The number of rows.
labelPair sizes() const noexcept
Return row/column sizes.
void checki(const label irow) const
Check index i is within valid range [0, m).
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe).
void checkSize() const
Check that dimensions are positive, non-zero.
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).
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.
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.
const Type * operator[](const label irow) const
Return const pointer to data in the specified row - rowData().
void checkj(const label jcol) const
Check index j is within valid range [0, n).
Foam::tmp< Foam::Field< Type > > AmulImpl(const ListType &x) const
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous...
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.
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
Foam::tmp< Foam::Field< Type > > TmulImpl(const ListType &x) const
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static constexpr direction nCols
static constexpr direction mRows
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 ...
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
A pair of labels.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).