29 #define CHECK_MATRIX_IS_SQUARE(a, b) \ 32 FatalErrorInFunction \ 33 << "Attempt to create a non-square matrix (" \ 34 << a << ", " << b << ')' << nl << abort(FatalError); \ 70 template<
class AnyType>
79 for (label i = 0; i <
n; ++i)
81 this->operator()(i, i) = pTraits<Type>::one;
87 template<
class AnyType>
91 const Identity<AnyType>
94 Matrix<SquareMatrix<Type>, Type>(dims,
Foam::zero{})
98 for (label i = 0; i < dims.first(); ++i)
111 Matrix<SquareMatrix<Type>, Type>(dims)
158 template<
class MatrixType>
171 template<
class MatrixType>
258 for (label
n = 0;
n < this->
n() - 1; ++
n)
260 for (label m = this->m() - 1;
n < m; --m)
262 if (SMALL <
mag((*
this)(
n, m) - (*
this)(m,
n)))
275 for (label i = 0; i < this->m(); ++i)
277 for (label j = 0; j < this->
n(); ++j)
279 const Type& val = (*this)(i, j);
281 if ((i == j) || (i - 1 == j) || (i + 1 == j))
283 if (
mag(val) < SMALL)
288 else if (SMALL <
mag(val))
338 for (label i = 0; i < f1f2T.m(); ++i)
340 for (label j = 0; j < f1f2T.n(); ++j)
342 f1f2T(i, j) = f1[i]*f2[j];
357 #undef CHECK_MATRIX_IS_SQUARE const T & first() const noexcept
Access the first element.
void size(const label n)
Older name for setAddressableSize.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
patchWriters resize(patchIds.size())
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
autoPtr< SquareMatrix< Type > > clone() const
Clone.
A traits class, which is primarily used for primitives and vector-space.
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.
A templated block of an (m x n) matrix of type <MatrixType>.
bool symmetric() const
Return true if the square matrix is effectively symmetric/Hermitian.
void shallowResize(const label m)
Resize the matrix without reallocating storage (unsafe)
label n() const noexcept
The number of columns.
Generic templated field type.
void resize_nocopy(const label n)
Resize the matrix without preserving existing content.
A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements, derived from Matrix.
errorManip< error > abort(error &err)
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
SquareMatrix()=default
Default construct.
#define CHECK_MATRIX_IS_SQUARE(a, b)
Pair< label > labelPair
A pair of labels.
void setSize(const label m)
Resize the matrix preserving the elements.
label m() const noexcept
The number of rows.
void resize(const label m)
Resize the matrix preserving the elements.
Foam::SquareMatrix< Type > symmOuter(const Field< Type > &f1, const Field< Type > &f2)
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...
Templated identity and dual space identity tensors derived from SphericalTensor.
SquareMatrix & operator=(const SquareMatrix &)=default
Copy assignment.
const T & second() const noexcept
Access the second element.
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix...
bool tridiagonal() const
Return true if the square matrix is reduced tridiagonal.