Go to the documentation of this file.
33 template<
class Form,
class Type>
36 const label len = size();
48 template<
class Form,
class Type>
57 template<
class Form,
class Type>
60 Matrix<Form, Type>(dims.first(), dims.second())
64 template<
class Form,
class Type>
67 Matrix<Form, Type>(dims.first(), dims.second(),
Zero)
71 template<
class Form,
class Type>
74 Matrix<Form, Type>(dims.first(), dims.second(), val)
78 template<
class Form,
class Type>
88 template<
class Form,
class Type>
91 return NullObjectRef<Matrix<Form, Type>>();
95 template<
class Form,
class Type>
102 template<
class Form,
class Type>
109 template<
class Form,
class Type>
112 return mRows_ * nCols_;
116 template<
class Form,
class Type>
123 template<
class Form,
class Type>
126 return !mRows_ || !nCols_;
130 template<
class Form,
class Type>
133 if (!mRows_ || !nCols_)
136 <<
"Attempt to access element from empty matrix"
139 if (i < 0 || mRows_ <= i)
142 <<
"Index " << i <<
" out of range 0 ... " << mRows_-1
148 template<
class Form,
class Type>
151 if (!mRows_ || !nCols_)
154 <<
"Attempt to access element from empty matrix"
157 if (j < 0 || nCols_ <= j)
160 <<
"index " << j <<
" out of range 0 ... " << nCols_-1
166 template<
class Form,
class Type>
169 if (mRows_ < 0 || nCols_ < 0)
172 <<
"Incorrect size (" << mRows_ <<
", " << nCols_ <<
')' <<
nl
179 template<
class Form,
class Type>
182 const label len = size();
189 for (label idx = 1; idx < len; ++idx)
191 if (v_[0] != v_[idx])
201 template<
class Form,
class Type>
208 template<
class Form,
class Type>
215 template<
class Form,
class Type>
218 return reinterpret_cast<const char*
>(v_);
222 template<
class Form,
class Type>
225 return reinterpret_cast<char*
>(v_);
229 template<
class Form,
class Type>
232 return mRows_*nCols_*
sizeof(Type);
236 template<
class Form,
class Type>
242 return (v_ + irow*nCols_);
246 template<
class Form,
class Type>
252 return (v_ + irow*nCols_);
256 template<
class Form,
class Type>
260 if (idx < 0 || this->size() <= idx)
263 <<
"index " << idx <<
" out of range 0 ... " << this->size()
271 template<
class Form,
class Type>
275 if (idx < 0 || this->size() <= idx)
278 <<
"index " << idx <<
" out of range 0 ... " << this->size()
286 template<
class Form,
class Type>
290 const label colIndex,
291 const label rowIndex,
297 len = mRows_ - rowIndex;
311 template<
class Form,
class Type>
315 const label rowIndex,
316 const label colIndex,
322 len = nCols_ - colIndex;
336 template<
class Form,
class Type>
340 const label rowIndex,
341 const label colIndex,
346 if (szRows < 0) szRows = mRows_ - rowIndex;
347 if (szCols < 0) szCols = nCols_ - colIndex;
360 template<
class Form,
class Type>
361 template<
class VectorSpace>
365 const label rowIndex,
380 template<
class Form,
class Type>
384 const label colIndex,
385 const label rowIndex,
391 len = mRows_ - rowIndex;
405 template<
class Form,
class Type>
409 const label rowIndex,
410 const label colIndex,
416 len = nCols_ - colIndex;
430 template<
class Form,
class Type>
434 const label rowIndex,
435 const label colIndex,
440 if (szRows < 0) szRows = mRows_ - rowIndex;
441 if (szCols < 0) szCols = nCols_ - colIndex;
454 template<
class Form,
class Type>
455 template<
class VectorSpace>
459 const label rowIndex,
474 template<
class Form,
class Type>
481 template<
class Form,
class Type>
489 template<
class Form,
class Type>
495 return this->AmulImpl(
x);
499 template<
class Form,
class Type>
506 return this->AmulImpl(
x);
510 template<
class Form,
class Type>
516 return this->TmulImpl(
x);
520 template<
class Form,
class Type>
527 return this->TmulImpl(
x);
533 template<
class Form,
class Type>
541 template<
class Form,
class Type>
545 return v_ + (mRows_ * nCols_);
549 template<
class Form,
class Type>
557 template<
class Form,
class Type>
561 return v_ + (mRows_ * nCols_);
565 template<
class Form,
class Type>
573 template<
class Form,
class Type>
577 return v_ + (mRows_ * nCols_);
583 template<
class Form,
class Type>
594 return v_[irow*nCols_ + jcol];
598 template<
class Form,
class Type>
609 return v_[irow*nCols_ + jcol];
613 template<
class Form,
class Type>
619 return v_ + irow*nCols_;
623 template<
class Form,
class Type>
629 return v_ + irow*nCols_;
641 template<
class Form,
class Type>
653 template<
class Form,
class Type,
class Addr>
654 inline tmp<Field<Type>>
operator*
665 template<
class Form,
class Type>
666 inline tmp<Field<Type>>
operator*
677 template<
class Form,
class Type,
class Addr>
678 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)
iterator end() noexcept
Return an iterator to end traversing a Matrix.
char * data_bytes() noexcept
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.
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_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
std::streamsize size_bytes() const noexcept
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)
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.
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
static const Matrix< Form, Type > & null()
Return a null Matrix.
const Type * cdata() const noexcept
const char * cdata_bytes() 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.
Matrix() noexcept
Default construct (empty matrix)
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...