Changeset 2558 in Sophya for trunk/SophyaProg/Tests/tsttminv.cc
- Timestamp:
- Jul 22, 2004, 3:38:05 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/tsttminv.cc
r2557 r2558 26 26 #define ALSO_LAPACK_EV 27 27 #define ALSO_LAPACK_EV_SYM 28 #define ALSO_LAPACK_SVD 28 29 29 30 ////////////////////////////////////////////////// … … 79 80 void Hermitian(TMatrix< TYPE >& A); 80 81 r_8 Check_Mat_Ident(TMatrix< TYPE >& A); 82 r_8 Check_Mat_Zero(TMatrix< TYPE >& A); 81 83 r_8 Check_Mat_VecCol_0(TMatrix< TYPE >& A); 82 84 void Check_Mat_VecCol_2(TMatrix< complex<TYPER> >& A); … … 271 273 cout<<"Compute AiA = A * InvA"<<endl; 272 274 TMatrix< TYPE > AiA(N,N); AiA = Ainput * InvA; 273 cout<<"------------ TMatrix AiA = A * InvA:"<<endl;274 275 if(nprline>0) {cout<<AiA; cout<<endl;} 275 276 //-- Check … … 321 322 cout<<"Compute AiA = A * InvA"<<endl; 322 323 TMatrix< TYPE > AiA(N,N); AiA = Ainput * InvA; 323 cout<<"------------ TMatrix AiA = A * InvA:"<<endl;324 324 if(nprline>0) {cout<<AiA; cout<<endl;} 325 325 //-- Check … … 426 426 427 427 428 //////////////////////////////////////////////// 429 ///////////// Test avec Lapack SVD ///////////// 430 //////////////////////////////////////////////// 431 #if defined(USE_LAPACK) && defined(ALSO_LAPACK_SVD) 432 { 433 cout<<"\n=========================================="<<endl; 434 cout<<"------------ SVD decompositon LapackSVD "<<endl; 435 A=Ainput; 436 TVector< TYPE > S(N,N); TMatrix< TYPE > U(N,N); TMatrix< TYPE > VT(N,N); 437 //-- Decompositon 438 int_4 info = LapackSVD(A,S,U,VT); 439 cout<<"info="<<info<<endl; 440 PrtTim("--- End of LapackSVD decompositon ---"); 441 if(nprline>0) {cout<<S; cout<<endl;} 442 double smax = ABS_VAL(S(0)), smin = ABS_VAL(S(N-1)); 443 cout<<" Smin = |"<<S(N-1)<<"| = "<<smin<<", " 444 <<" Smax = |"<<S(0)<<"| = "<<smax<<", " 445 <<" --> Smin/Smax = "<<smin/smax<<endl; 446 //-- A = U*S*VT 447 cout<<"Compute A = U*S*VT"<<endl; 448 TMatrix< TYPE > AmUSVt(N,N); AmUSVt = U; 449 for(int i=0;i<N;i++) for(int j=0;j<N;j++) AmUSVt(i,j) *= S(j); 450 AmUSVt *= VT; AmUSVt -= Ainput; 451 if(nprline>0) {cout<<AmUSVt; cout<<endl;} 452 //-- Check 453 Check_Mat_Zero(AmUSVt); 454 PrtTim("--- End of LapackSVD Test ---"); 455 } 456 #endif 457 458 428 459 /////////////////////////////////////////////// 429 460 ///////// Test Inversion avec GausPiv ///////// … … 493 524 cout<<"Ecart maximum par rapport a 0 hors diagonale = "<<vmaxh<<endl; 494 525 return (vmaxd>vmaxh)? vmaxd: vmaxh; 526 } 527 528 ////------------------------------------------------------- 529 r_8 Check_Mat_Zero(TMatrix< TYPE >& A) 530 // Compute the biggest difference element by element of A / Zero matrix 531 { 532 int_4 N = A.NRows(); 533 r_8 vmax = -1.; 534 for(int i=0;i<N;i++) for(int j=0;j<N;j++) 535 if( ABS_VAL(A(i,j)) > vmax ) vmax = ABS_VAL(A(i,j)); 536 cout<<"Ecart maximum par rapport a zero = "<<vmax<<endl; 537 return vmax; 495 538 } 496 539
Note:
See TracChangeset
for help on using the changeset viewer.