Changeset 2566 in Sophya for trunk/SophyaProg/Tests/tsttminv.cc
- Timestamp:
- Jul 27, 2004, 9:58:18 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/tsttminv.cc
r2562 r2566 24 24 #define ALSO_LAPACK_INV_SYM 25 25 #define ALSO_LAPACK_INV_LSS 26 #define ALSO_LAPACK_INV_LSS_SVD 26 27 #define ALSO_LAPACK_EV 27 28 #define ALSO_LAPACK_EV_SYM … … 264 265 { 265 266 cout<<"\n=========================================="<<endl; 266 cout<<"------------ Inversion LAPACK "<<endl;267 cout<<"------------ Inversion LAPACK (LU factorization)"<<endl; 267 268 A = Ainput; 268 269 //-- Inversion … … 288 289 { 289 290 cout<<"\n=========================================="<<endl; 290 cout<<"------------ Inversion LAPACK sym "<<endl;291 cout<<"------------ Inversion LAPACK symetric (LU factorization)"<<endl; 291 292 TMatrix< TYPE > Asym(N,N); Asym=Ainput; Symetrize(Asym); A=Asym; 292 293 //-- Inversion … … 313 314 { 314 315 cout<<"\n=========================================="<<endl; 315 cout<<"------------ Inversion LAPACK LeastSquare "<<endl;316 cout<<"------------ Inversion LAPACK LeastSquare (QR or LQ factorization)"<<endl; 316 317 A = Ainput; 317 318 //-- Inversion … … 327 328 Check_Mat_Ident(AiA); 328 329 PrtTim("--- End of LapackLeastSquareSolve Test ---"); 330 } 331 #endif 332 333 334 //////////////////////////////////////////////// 335 ///////// Test avec Lapack LeastSquare ///////// 336 //////////////////////////////////////////////// 337 #if defined(USE_LAPACK) && defined(ALSO_LAPACK_INV_LSS_SVD) 338 { 339 cout<<"\n=========================================="<<endl; 340 cout<<"------------ Inversion LAPACK LeastSquare (SVD decomposition)"<<endl; 341 A = Ainput; 342 //-- Inversion 343 TMatrix< TYPE > InvA(N,N); InvA = IdentityMatrix(1.,N); 344 TVector<r_8> S; 345 int_4 rank; 346 r_8 rcond = -1.; 347 int_4 info = LapackLeastSquareSolveSVD_DC(A,InvA,S,rank,rcond); 348 cout<<"info="<<info<<" (rank="<<rank<<")"<<endl; 349 PrtTim("--- End of LapackLeastSquareSolveSVD_DC Inversion ---"); 350 if(nprline>0) {cout<<S; cout<<endl;} 351 double smax = fabs(S(0)), smin = fabs(S(S.Size()-1)); 352 cout<<" Smin = |"<<S(S.Size()-1)<<"| = "<<smin<<", " 353 <<" Smax = |"<<S(0)<<"| = "<<smax<<", " 354 <<" --> Smin/Smax = "<<smin/smax<<endl; 355 //-- AiA = A * InvA 356 cout<<"Compute AiA = A * InvA"<<endl; 357 TMatrix< TYPE > AiA(N,N); AiA = Ainput * InvA; 358 if(nprline>0) {cout<<AiA; cout<<endl;} 359 //-- Check 360 Check_Mat_Ident(AiA); 361 PrtTim("--- End of LapackLeastSquareSolveSVD_DC Test ---"); 329 362 } 330 363 #endif … … 466 499 cout<<"------------ SVD decompositon LapackSVD_DC "<<endl; 467 500 A=Ainput; 468 TVector< TYPE> S; TMatrix< TYPE > U; TMatrix< TYPE > VT;501 TVector< r_8 > S; TMatrix< TYPE > U; TMatrix< TYPE > VT; 469 502 //-- Decompositon 470 503 int_4 info = LapackSVD_DC(A,S,U,VT); … … 472 505 PrtTim("--- End of LapackSVD_DC decompositon ---"); 473 506 if(nprline>0) {cout<<S; cout<<endl;} 474 double smax = ABS_VAL(S(0)), smin = ABS_VAL(S(N-1));507 double smax = fabs(S(0)), smin = fabs(S(N-1)); 475 508 cout<<" Smin = |"<<S(N-1)<<"| = "<<smin<<", " 476 509 <<" Smax = |"<<S(0)<<"| = "<<smax<<", " … … 479 512 cout<<"Compute A = U*S*VT"<<endl; 480 513 TMatrix< TYPE > AmUSVt(N,N); AmUSVt = U; 481 for(int i=0;i<N;i++) for(int j=0;j<N;j++) AmUSVt(i,j) *= S(j);514 for(int i=0;i<N;i++) for(int j=0;j<N;j++) AmUSVt(i,j) *= (TYPE) S(j); 482 515 AmUSVt *= VT; AmUSVt -= Ainput; 483 516 if(nprline>0) {cout<<AmUSVt; cout<<endl;}
Note:
See TracChangeset
for help on using the changeset viewer.