public double[][] cholesky(double[][] a){
double[][] l=new double[a.length][a.length];
double s;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < i; j++) {
s=0;
for (int k = 0; k < j; k++) {
s+=l[i][k]*l[j][k];
}
l[i][j]=(a[i][j]-s)/l[j][j];
}
s=0;
for (int k = 0; k < i; k++) {
s+= pow(l[i][k],2);
}
l[i][i]=sqrt((a[i][i]-s));
}
return l;
}This is part of the Matrices project.
No comments:
Post a Comment