Fixed decomposition. Add sample matrix.

This commit is contained in:
Guilhem Lavaux 2011-12-14 17:40:10 -05:00
parent cf279bbb19
commit 196e17c242
3 changed files with 89 additions and 38 deletions

View file

@ -1,3 +1,4 @@
#include <fstream>
#include <cstring>
#include <iostream>
#include <iomanip>
@ -26,28 +27,39 @@ struct MatrixOp
}
};
int main()
int main(int argc, char **argv)
{
MatrixOp M;
double norm_E;
ifstream fi(argv[1]);
ofstream f("eskowed.txt");
CholeskyEskow<double,MatrixOp> chol;
M.N = 6;
fi >> M.N;
M.M.resize(M.N*M.N);
memcpy(&M.M[0], &Hartmann_Matrix[0][0], sizeof(double)*36);
for (int i = 0; i < M.N; i++)
{
for (int j = 0; j < M.N; j++)
{
fi >> M(i,j);
if (j > i)
M(i,j) =0;
}
}
CholeskyEskow::cholesky_eskow(M, M.N, norm_E);
chol.cholesky(M, M.N, norm_E);
for (int i = 0; i < M.N; i++)
{
for (int j = 0; j < M.N; j++)
{
if (j > i)
cout << "0 ";
f << "0 ";
else
cout << setprecision(25) << M(i,j) << " ";
f << setprecision(25) << M(i,j) << " ";
}
cout << endl;
f << endl;
}
return 0;
}