Go to the documentation of this file.
33 template<
class Form,
class Type>
36 const label len = size();
47 template<
class Form,
class Type>
56 template<
class Form,
class Type>
59 Matrix<Form, Type>(dims.first(), dims.second())
63 template<
class Form,
class Type>
66 Matrix<Form, Type>(dims.first(), dims.second(),
Zero)
70 template<
class Form,
class Type>
73 Matrix<Form, Type>(dims.first(), dims.second(), val)
77 template<
class Form,
class Type>
87 template<
class Form,
class Type>
90 return NullObjectRef<Matrix<Form, Type>>();
94 template<
class Form,
class Type>
101 template<
class Form,
class Type>
108 template<
class Form,
class Type>
111 return mRows_ * nCols_;
115 template<
class Form,
class Type>
122 template<
class Form,
class Type>
125 return !mRows_ || !nCols_;
129 template<
class Form,
class Type>
132 if (!mRows_ || !nCols_)
135 <<
"Attempt to access element from empty matrix"
138 if (i < 0 || mRows_ <= i)
141 <<
"Index " << i <<
" out of range 0 ... " << mRows_-1
147 template<
class Form,
class Type>
150 if (!mRows_ || !nCols_)
153 <<
"Attempt to access element from empty matrix"
156 if (j < 0 || nCols_ <= j)
159 <<
"index " << j <<
" out of range 0 ... " << nCols_-1
165 template<
class Form,
class Type>
168 if (mRows_ < 0 || nCols_ < 0)
171 <<
"Incorrect size (" << mRows_ <<
", " << nCols_ <<
')' <<
nl
178 template<
class Form,
class Type>
181 const label len = size();
188 for (label idx = 1; idx < len; ++idx)
190 if (v_[0] != v_[idx])
200 template<
class Form,
class Type>
207 template<
class Form,
class Type>
214 template<
class Form,
class Type>
220 return (v_ + irow*nCols_);
224 template<
class Form,
class Type>
230 return (v_ + irow*nCols_);
234 template<
class Form,
class Type>
238 if (idx < 0 || this->size() <= idx)
241 <<
"index " << idx <<
" out of range 0 ... " << this->size()
249 template<
class Form,
class Type>
253 if (idx < 0 || this->size() <= idx)
256 <<
"index " << idx <<
" out of range 0 ... " << this->size()
264 template<
class Form,
class Type>
268 const label colIndex,
269 const label rowIndex,
275 len = mRows_ - rowIndex;
289 template<
class Form,
class Type>
293 const label rowIndex,
294 const label colIndex,
300 len = nCols_ - colIndex;
314 template<
class Form,
class Type>
318 const label rowIndex,
319 const label colIndex,
324 if (szRows < 0) szRows = mRows_ - rowIndex;
325 if (szCols < 0) szCols = nCols_ - colIndex;
338 template<
class Form,
class Type>
339 template<
class VectorSpace>
343 const label rowIndex,
358 template<
class Form,
class Type>
362 const label colIndex,
363 const label rowIndex,
369 len = mRows_ - rowIndex;
383 template<
class Form,
class Type>
387 const label rowIndex,
388 const label colIndex,
394 len = nCols_ - colIndex;
408 template<
class Form,
class Type>
412 const label rowIndex,
413 const label colIndex,
418 if (szRows < 0) szRows = mRows_ - rowIndex;
419 if (szCols < 0) szCols = nCols_ - colIndex;
432 template<
class Form,
class Type>
433 template<
class VectorSpace>
437 const label rowIndex,
452 template<
class Form,
class Type>
459 template<
class Form,
class Type>
467 template<
class Form,
class Type>
473 return this->AmulImpl(
x);
477 template<
class Form,
class Type>
484 return this->AmulImpl(
x);
488 template<
class Form,
class Type>
494 return this->TmulImpl(
x);
498 template<
class Form,
class Type>
505 return this->TmulImpl(
x);
511 template<
class Form,
class Type>
519 template<
class Form,
class Type>
523 return v_ + (mRows_ * nCols_);
527 template<
class Form,
class Type>
535 template<
class Form,
class Type>
539 return v_ + (mRows_ * nCols_);
543 template<
class Form,
class Type>
551 template<
class Form,
class Type>
555 return v_ + (mRows_ * nCols_);
561 template<
class Form,
class Type>
572 return v_[irow*nCols_ + jcol];
576 template<
class Form,
class Type>
587 return v_[irow*nCols_ + jcol];
591 template<
class Form,
class Type>
597 return v_ + irow*nCols_;
601 template<
class Form,
class Type>
607 return v_ + irow*nCols_;
619 template<
class Form,
class Type>
631 template<
class Form,
class Type,
class Addr>
632 inline tmp<Field<Type>>
operator*
643 template<
class Form,
class Type>
644 inline tmp<Field<Type>>
operator*
655 template<
class Form,
class Type,
class Addr>
656 inline tmp<Field<Type>>
operator*
A class for managing temporary objects.
label n() const noexcept
The number of columns.
static constexpr const zero Zero
Global zero (0)
autoPtr< mType > clone() const
Clone.
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
void checkj(const label jcol) const
Check index j is within valid range [0, n)
labelPair sizes() const
Return row/column sizes.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Pair< label > labelPair
A pair of labels.
const_iterator cend() const
Return const_iterator to end traversing a constant Matrix.
patchWriters resize(patchIds.size())
const Type & at(const label idx) const
Linear addressing const element access.
A templated block of an (m x n) matrix of type <MatrixType>.
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row's subset of Matrix.
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.
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.
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)
const Type * operator[](const label irow) const
Return const pointer to data in the specified row - rowData().
errorManip< error > abort(error &err)
iterator begin()
Return an iterator to begin traversing a Matrix.
iterator end()
Return an iterator to end traversing a Matrix.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool uniform() const
True if all entries have identical values, and Matrix is non-empty.
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.
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
static const Matrix< Form, Type > & null()
Return a null Matrix.
const_iterator cbegin() const
Return const_iterator to begin traversing a constant Matrix.
const Type * cdata() const noexcept
ConstMatrixBlock< mType > block(const label rowIndex, const label colIndex) const
Access Field as a ConstMatrixBlock.
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....
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...