Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96390357
cholesky.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Dec 26, 08:10
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Dec 28, 08:10 (2 d)
Engine
blob
Format
Raw Data
Handle
23161814
Attached To
R1448 Lenstool-HPC
cholesky.c
View Options
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
/* Cholesky decomposition. Taken from nR 2.9
Inputs:
n, integer
a, n x n matrix
Returns:
The Cholesky factor L is returned in the
lower triangle of a, except for its diagonal
elements which are returned in p.
p must be allocated before entering the function.
*/
void cholesky(double **a, int n, double *p)
{
int i, j, k;
double sum;
for (i = 0; i < n; i++)
for (j = i; j < n; j++)
{
sum = a[i][j];
for ( k = i - 1; k >= 0; k-- )
sum -= a[i][k] * a[j][k];
if ( i == j )
{
if ( sum <= 0. )
{
fprintf(stderr, "ERROR in cholesky.c. a, with rounding errors, is not positive definie\n");
exit(1);
}
p[i] = sqrt(sum);
}
else
a[j][i] = sum / p[i];
}
}
/* End of cholesky.c */
Event Timeline
Log In to Comment