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);
75 LLT(i, i) =
sqrt(sum);
80 <<
"Cholesky decomposition failed, "
81 "matrix is not symmetric positive definite"
90template<
template<
typename>
class ListContainer>
91void Foam::LLTMatrix<Type>::solveImpl
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)
127 x[i] =
sum/LLT(i, i);
136 const UList<Type>& source
139 solveImpl(
x, source);
151 solveImpl(
x, source);
162 solve(tresult.ref(), source);
177 solve(tresult.ref(), source);
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
label size() const noexcept
The number of elements in the list.
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.
void decompose(const SquareMatrix< Type > &mat)
Copy matrix and perform Cholesky decomposition.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
SquareMatrix()=default
Default construct.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
A class for managing temporary objects.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
dimensionedScalar sqrt(const dimensionedScalar &ds)
errorManip< error > abort(error &err)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...