50 const label m = LLT.
m();
52 for (label i = 0; i < m; ++i)
54 for (label j = 0; j < m; ++j)
64 for (label
k = 0;
k < j; ++
k)
66 sum -= LLT(i,
k)*LLT(j,
k);
71 LLT(i, j) =
sum/LLT(j, j);
80 <<
"Cholesky decomposition failed, " 81 "matrix is not symmetric positive definite" 90 template<
template<
typename>
class ListContainer>
94 const ListContainer<Type>& source
103 const SquareMatrix<Type>& LLT = *
this;
104 const label m = LLT.
m();
106 for (label i = 0; i < m; ++i)
108 Type
sum = source[i];
110 for (label j = 0; j < i; ++j)
115 x[i] =
sum/LLT(i, i);
118 for (label i = m - 1; i >= 0; --i)
122 for (label j = i + 1; j < m; ++j)
136 const UList<Type>& source
139 solveImpl(
x, source);
151 solveImpl(
x, source);
162 solve(tresult.ref(), source);
177 solve(tresult.ref(), source);
void size(const label n)
Older name for setAddressableSize.
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.
void decompose(const SquareMatrix< Type > &mat)
Copy matrix and perform Cholesky decomposition.
dimensionedScalar sqrt(const dimensionedScalar &ds)
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.
LLTMatrix()=default
Default construct.
void solve(List< Type > &x, const UList< Type > &source) const
Solve the linear system with the given source and return the solution in the argument x...
label k
Boltzmann constant.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
Generic templated field type.
label size() const noexcept
The number of elements in the list.
errorManip< error > abort(error &err)
label m() const noexcept
The number of rows.
A class for managing temporary objects.
Templated class to perform the Cholesky decomposition on a symmetric positive-definite matrix...
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)