(j, j)-v; (ajj <= 0)
{= false; result;
} = sqrt (ajj); (j, j) = ajj;
// Compute elements J +1: N of row J.
if (j
{(i = 0; i <= j-1; i + +)
{= a (i, j); :: vsub (& a (j, j +1), & a (i, j +1), ap :: vlen (j + 1, n-1), v);
} = 1/ajj; :: vmul (& a (j, j +1), ap :: vlen (j +1, n-1), v);
}
}
}
{
// Compute the Cholesky factorization A = L * L '. (j = 0; j <= n-1; j + +)
{
// Compute L (J, J) and test for non-positive-definiteness. = ap :: vdotproduct (& a (j, 0), & a (j, 0), ap :: vlen (0, j-1)); = a (j, j)-v; (ajj <= 0)
{= false; result;
} = sqrt (ajj); (j, j) = ajj;
// Compute elements J +1: N of column J.
if (j
{(i = j +1; i <= n-1; i + +)
{= ap :: vdotproduct (& a (i, 0), & a (j, 0), ap :: vlen (0, j-1)); (i, j ) = a (i, j)-v;
} = 1/ajj; :: vmul (a.getcolumn (j, j +1, n-1), v);
}
}
} result;
}
/***************************************** *************************
Obsolete 1-based subroutine.
****************************************** ************************/
bool choleskydecomposition (ap :: real_2d_array & a, int n, bool isupper)
{result; i; j;
double ajj; v; jm1;
int jp1;
//
// Test the input parameters.
// :: ap_error :: make_assertion (n> = 0, "Error in CholeskyDecomposition: incorrect function arguments");
//
// Quick return if possible
// = true; (n == 0)
{result;
} (isupper)
{
//
// Compute the Cholesky factorization A = U '* U.
// (j = 1; j <= n; j + +)
{
//
// Compute U (J, J) and test for non-positive-definiteness.
// = j-1; = ap :: vdotproduct (a.getcolumn (j, 1, jm1), a.getcolumn (j, 1, jm1)); = a (j, j )-v; (ajj <= 0)
{= false; result;
} = sqrt (ajj); (j, j) = ajj;
//
// Compute elements J +1: N of row J.
// (j
{(i = j ...