Commit b036aecd by Francois Gygi

### added eigenvalue and cholesky tests


git-svn-id: http://qboxcode.org/svn/qb/trunk@354 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 4de1ab14
 // $Id: testMatrix.C,v 1.9 2004-12-10 01:06:06 fgygi Exp$ // $Id: testMatrix.C,v 1.10 2005-02-04 22:02:09 fgygi Exp$ // // test Matrix // ... ... @@ -32,8 +32,8 @@ using namespace std; #include "Context.h" #include "Matrix.h" int aa(int i, int j) { return 1.0/(i+1)+2.0/(j+1); } int bb(int i, int j) { return i-j-3; } double aa(int i, int j) { return 1.0/(i+1)+2.0*i/(j+1); } double bb(int i, int j) { return i-j-3; } int main(int argc, char **argv) { ... ... @@ -223,23 +223,31 @@ int main(int argc, char **argv) cout << " MFlops: " << (2.0e-6*m_c*n_c*kmax) / tm.real() << endl; } #if 0 #if 1 double norma=a.nrm2(); if(mype == 0)cout<<"Norm(a)="< w(c.m()); c.syev('l',w,z); //c.syevx('l',w,z,1.e-5); if (mype == 0) cout << " done" << endl; tm.stop(); if (mype == 0) cout << "Eigenproblem time: " << tm.real() << endl; } // Gram-Schmidt orthogonalization of matrix a for ( int m = 0; m < a.nblocks(); m++ ) for ( int l = 0; l < a.mblocks(); l++ ) for ( int y = 0; y < a.nbs(m); y++ ) for ( int x = 0; x < a.mbs(l); x++ ) { int i = a.i(l,x); int j = a.j(m,y); double aij = aa(i,j); int iii = x + l*a.mb(); int jjj = y + m*a.nb(); int ival = iii + jjj * a.mloc(); if ( i == j ) a[ival] = i + 1.e-6*drand48(); else a[ival] = 1.e-6*drand48(); } DoubleMatrix s(a.context(),a.n(),a.n(),a.nb(),a.nb()); tm.reset(); tm.start(); s.syrk('l','t',2.0,a,0.0); if (mype == 0) cout << "Gram syrk time: " << tm.real() << endl; tm.reset(); tm.start(); s.syr('l',-1.0,a,0,'r'); tm.stop(); if (mype == 0) cout << "Gram syr time: " << tm.real() << endl; // Cholesky decomposition tm.reset(); tm.start(); s.potrf('l'); // Cholesky decomposition: S = L * L^T tm.stop(); if (mype == 0) cout << "Gram Cholesky time: " << tm.real() << endl; // Triangular solve tm.reset(); tm.start(); // solve triangular system X * L^T = C a.trsm('r','l','t','n',1.0,s); tm.stop(); if (mype == 0) cout << "Gram triangular solve time: " << tm.real() << endl; #endif } #ifdef USE_MPI ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!