Foam::scalar Foam::det(SquareMatrix<Type>& matrix) { labelList pivotIndices(matrix.n()); label sign; LUDecompose(matrix, pivotIndices, sign); return detDecomposed(matrix, sign); }
Foam::scalar Foam::det(const SquareMatrix<Type>& matrix) { SquareMatrix<Type> matrixTmp = matrix; labelList pivotIndices(matrix.n()); label sign; LUDecompose(matrixTmp, pivotIndices, sign); return detDecomposed(matrixTmp, sign); }
Foam::scalar Foam::detDecomposed ( const SquareMatrix<Type>& matrix, const label sign ) { scalar diagProduct = 1.0; for (label i = 0; i < matrix.n(); ++i) { diagProduct *= matrix[i][i]; } return sign*diagProduct; }