46 [&](label i, label j){ return compare((*this)(i,i), (*this)(j,j)); }
57 if (this->m() !=
p.size())
60 <<
"Attempt to column-reorder according to an uneven list: " <<
nl
61 <<
"SquareMatrix diagonal size = " << this->m() <<
nl
62 <<
"Permutation list size = " <<
p.size() <<
nl
67 SquareMatrix<Type> reordered(this->sizes());
70 for (
const label i :
p)
72 reordered.subColumn(j) = this->subColumn(i);
76 this->transfer(reordered);
83template<
class AnyType>
88 for (label i = 0; i < this->
n(); ++i)
90 this->operator()(i, i) = pTraits<Type>::one;
112 for (label i = 0; i < matrix.
m(); ++i)
114 diagProduct *= matrix(i, i);
117 return sign*diagProduct;
157 if (mat.
m() !=
p.size())
160 <<
"Attempt to column-reorder according to an uneven list: " <<
nl
161 <<
"SquareMatrix diagonal size = " << mat.
m() <<
nl
162 <<
"Permutation list size = " <<
p.size() <<
nl
170 for (
const label i :
p)
183class typeOfInnerProduct<Type, SquareMatrix<Type>, SquareMatrix<Type>>
Templated identity and dual space identity tensors derived from SphericalTensor.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
constexpr Matrix() noexcept
const Type & operator()(const label irow, const label jcol) const
label m() const noexcept
The number of rows.
void transfer(Matrix< SquareMatrix< Type >, Type > &mat)
labelPair sizes() const noexcept
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of Matrix.
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
SquareMatrix()=default
Default construct.
labelList sortPermutation(CompOp &compare) const
Return a sort permutation using the given comparison operator on the diagonal entries.
void applyPermutation(const labelUList &p)
Column-reorder this Matrix according to the given permutation.
SquareMatrix & operator=(const SquareMatrix &)=default
Copy assignment.
A traits class, which is primarily used for primitives and vector-space.
SquareMatrix< Type > type
Abstract template class to provide the form resulting from the inner-product of two forms.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
DiagonalMatrix< Type > applyPermutation(const DiagonalMatrix< Type > &mat, const labelUList &p)
Return Matrix column-reordered according to a given permutation labelList.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
scalar detDecomposed(const SquareMatrix< Type > &matrix, const label sign)
Return the determinant of the LU decomposed SquareMatrix.
constexpr char nl
The newline '\n' character (0x0a).