]>
If Cut/Copy and Paste fails, then click here for download.
/*
*
* Cholesky factorization of a symmetric, positive definite tridiagonal
* matrix `A' according to `A=transpose(U)*U=L*transpose(L)'. On input, the
* main diagonal of `A' is stored in the vector `d', and one of the secondary
* diagonals is stored in the vector `e'. The operation works inplace.
*
*/
unsigned int
cholfactridiag (unsigned int n, double *d, double *e)
{
unsigned int i;
double f;
if (n == 0) {
return (0);
}
if (isign3 (*(d + 0)) != 1) {
return (1);
}
*(d + 0) = sqrt (*(d + 0));
for (i = 1; i < n; i++) {
*(e + i - 1) /= *(d + i - 1);
f = *(d + i) - *(e + i - 1) * *(e + i - 1);
if (isign3 (f) != 1) {
return (1);
}
*(d + i) = sqrt (f);
}
return (0);
}