Changeset 1567 in Sophya
- Timestamp:
- Jul 5, 2001, 5:46:30 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/lpk.cc
r1425 r1567 14 14 int lpk_linsolve_mtx(int n); 15 15 int lpk_svd_mtx(int l, int c, int wsf, bool covu=true); 16 int lpk_leastsquare_mtx(int l, int c); 16 17 17 18 static double TOLERANCE = 1.e-6; … … 31 32 << " linsolve: lpk_linsolve_mtx() LapackServer::LinSolve with TMatrix<r_8> \n" 32 33 << " svd: lpk_svd_mtx() LapackServer::SVD(a,s,u,vt) with TMatrix<r_8> \n" 33 << " svds: lpk_svd_mtx() LapackServer::SVD(a,s); with TMatrix<r_8> \n" 34 << " svds: lpk_svd_mtx() LapackServer::SVD(a,s); with TMatrix<r_8> \n" 35 << " lss: lpk_leastsquare_mtx() LapackServer::LeastSquareSolve() r_8 \n" 34 36 << " rzt: lpk_rzt_tarr() rztest_lapack with TArray<r_4> \n" << endl; 35 37 exit(0); … … 52 54 else if (opt == "svd") rc = lpk_svd_mtx(l,c,wsf,true); 53 55 else if (opt == "svds") rc = lpk_svd_mtx(l,c,wsf,false); 56 else if (opt == "lss") rc = lpk_leastsquare_mtx(l,c); 54 57 else if (opt == "rzt") rc = lpk_rzt_arr(l); 55 58 else { cout << " Unknown option " << opt << " ! " << endl; rc = 66; } … … 160 163 } 161 164 165 // ----------------------------------------------------------------------- 166 /* Nouvelle-Fonction */ 167 int lpk_leastsquare_mtx(int m, int n) 168 { 169 BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping); 170 cout << " lpk_leastsquare_mtx() - Test of LapackLeastSquareSolve " << endl; 171 172 Matrix a(m , n), aa; 173 a = RandomSequence(RandomSequence::Gaussian, 0., 4.); 174 aa = a; 175 Vector x(n),noise(m),b,bx; 176 x = RandomSequence(RandomSequence::Gaussian, 2., 1.); 177 double signoise = 0.1; 178 noise = RandomSequence(RandomSequence::Gaussian, 0., 0.1); 179 b = a*x; 180 bx = b+noise; 181 182 cout << " ---- lpk_leastsquare_tmtx() LapackLeastSquareSolve<r_8> ---- " << endl; 183 cout << " ------------ Matrix A = \n " << a << "\n" << endl; 184 cout << " ------------ Vector B = \n " << bx << "\n" << endl; 185 cout << " ------------ Vector X = \n " << x << "\n" << endl; 186 187 cout << "\n Calling LapackLeastSquareSolve(a,bx) .... " << endl; 188 PrtTim(" Calling LapackLeastSquareSolve() "); 189 LapackLeastSquareSolve(aa, bx); 190 PrtTim(" End LapackLeastSquareSolve() "); 191 bx.Share(bx(Range(0,0,n))); 192 cout << " ------------ Result X = \n " << bx << "\n" << endl; 193 cout << " ------------ X-X_Real = \n " << bx-x << "\n" << endl; 194 Vector diff = b-a*bx; 195 PrtTim(" End of Compute(diff)"); 196 cout << " ------------ Matrix diff b-a*x = \n " << diff << "\n" << endl; 197 double mean,sigma; 198 MeanSigma(diff, mean, sigma); 199 cout << " MeanSigma(diff) , Mean= " << mean << " Sigma=" << sigma 200 << " SigNoise= " << signoise << endl; 201 if ((fabs(mean) > signoise) || (fabs(sigma-signoise) > signoise)) { 202 cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 203 << endl; 204 return(99); 205 } 206 return(0); 207 208 } 209 210 162 211 void rztest_lapack(TArray<r_4>& aa, TArray<r_4>& bb); 163 212
Note:
See TracChangeset
for help on using the changeset viewer.