36 template<
class CompOp>
43 std::iota(
p.begin(),
p.end(), 0);
48 [&](label i, label j){
return compare((*
this)(i,i), (*
this)(j,j)); }
59 if (this->m() !=
p.size())
62 <<
"Attempt to column-reorder according to an uneven list: " <<
nl 63 <<
"SquareMatrix diagonal size = " << this->m() <<
nl 64 <<
"Permutation list size = " <<
p.size() <<
nl 69 SquareMatrix<Type> reordered(this->sizes());
72 for (
const label i :
p)
74 reordered.subColumn(j) = this->subColumn(i);
78 this->transfer(reordered);
85 template<
class AnyType>
90 for (label i = 0; i < this->
n(); ++i)
114 for (label i = 0; i < matrix.
m(); ++i)
116 diagProduct *= matrix(i, i);
119 return sign*diagProduct;
162 <<
"Attempt to column-reorder according to an uneven list: " <<
nl 163 <<
"SquareMatrix diagonal size = " << mat.
m() <<
nl 164 <<
"Permutation list size = " <<
p.
size() <<
nl 172 for (
const label i :
p)
185 class typeOfInnerProduct<Type, SquareMatrix<Type>, SquareMatrix<Type>>
dimensionedScalar sign(const dimensionedScalar &ds)
void size(const label n)
Older name for setAddressableSize.
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of Matrix.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void applyPermutation(const List< label > &p)
Column-reorder this Matrix according to a given permutation labelList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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)
A traits class, which is primarily used for primitives.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
labelPair sizes() const
Return row/column sizes.
void sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
label m() const noexcept
The number of rows.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
List< label > sortPermutation(CompOp &compare) const
Return a sort permutation labelList according to a given comparison on the diagonal entries...
DiagonalMatrix< Type > applyPermutation(const DiagonalMatrix< Type > &mat, const List< label > &p)
Return Matrix column-reordered according to a given permutation labelList.
Templated identity and dual space identity tensors derived from SphericalTensor.
SquareMatrix & operator=(const SquareMatrix &)=default
Copy assignment.
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix...
static constexpr const zero Zero
Global zero (0)