47#ifndef MATH_CHOLESKYDECOMPOSITION_HPP
48#define MATH_CHOLESKYDECOMPOSITION_HPP
53 template<
class MatrixType>
54 void CholeskyDecomposition(MatrixType& A, MatrixType& L) {
55 unsigned int n = A.getNRow();
56 assert(n == A.getNCol() && n == L.getNRow() && n == L.getNCol());
60 A.diagonals().abs().max() * (numeric_limits<RealType>::epsilon()) / 100;
62 for (
unsigned int j = 0; j < n; j++) {
64 for (
unsigned int k = 0; k < j; k++) {
67 for (
unsigned int i = 0; i < k; i++) {
68 s += L(k, i) * L(j, i);
72 if (std::abs(L(k, k)) > eps) {
73 s = (A(j, k) - s) / L(k, k);
82 isspd = isspd && (abs(A(k, j) - A(j, k)) < eps);
85 isspd = isspd && (d > eps);
86 L(j, j) = sqrt(d > 0.0 ? d : 0.0);
87 for (
unsigned int k = j + 1; k < n; k++) {
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.