Changeset 1008 in Sophya
- Timestamp:
- May 16, 2000, 7:55:21 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/tsttminv.cc
r998 r1008 16 16 #include <math.h> 17 17 #include <unistd.h> 18 #include "timing.h" 18 19 #include "ntoolsinit.h" 19 20 #include "pexceptions.h" … … 55 56 uint_4 nprline = 10; 56 57 // Initialisation du pauvre de l'aleatoire 57 uint_4 nalea = 0; 58 uint_4 nalea = 0; 59 // data scaling for gauss pivoting and determinant 60 int tscal = 1; 61 bool detok=false; 62 bool timok = false; 58 63 //-------------------------------------------------------- 59 64 60 65 //-- Decodage arguments 61 66 char c; 62 while((c = getopt(narg,arg,"h v:l:a:")) != -1) {67 while((c = getopt(narg,arg,"hdtv:l:a:n:")) != -1) { 63 68 switch (c) { 64 69 case 'v' : … … 71 76 sscanf(optarg,"%d",&nalea); 72 77 break; 78 case 'n' : 79 sscanf(optarg,"%d",&tscal); 80 break; 81 case 'd' : 82 detok = true; 83 break; 84 case 't' : 85 timok = true; 86 break; 73 87 case 'h' : 74 cout<<"tsttminv [-h] [-v N,scale,nbig,vbig] [-l nprline] [-a nalea]"<<endl; 75 cout<<"matrix filled with : {[-1,1] +/- vbig(nbig time)}*scale"<<endl; 88 cout<<"tsttminv [-h] [-v N,scale,nbig,vbig] [-l nprline] [-a nalea]"<<endl 89 <<" [-n typs] [-d] [-t]"<<endl 90 <<"matrix filled with : {[-1,1] +/- vbig(nbig time)}*scale"<<endl 91 <<"-n 0/1/2 : data scaling 0=no, 1=global (def), 2=row-by-row"<<endl 92 <<"-d : also compute determinant"<<endl 93 <<"-t : do timing"<<endl; 76 94 exit(-1); 77 95 } … … 84 102 cout<<"Nombre de lignes de matrice a imprimer "<<nprline<<endl; 85 103 cout<<"Initialisation de l aleatoire par "<<nalea<<" tirages"<<endl; 104 cout<<"Data scaling "<<tscal<<" determinant="<<detok<<" timing="<<timok<<endl; 86 105 cout<<endl; 87 106 88 107 //-- Initialization arrays 89 108 SophyaInit(); 109 if(timok) InitTim(); 90 110 #ifdef ALSO_LAPACK 91 111 BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping); … … 101 121 A.Show(); 102 122 123 SimpleMatrixOperation< TYPE >::SetGausPivScal(tscal); 124 103 125 //-- Mise a zero 104 126 A = (TYPE) 0; … … 110 132 111 133 //-- Fill matrices 134 double vmax=-1.; 112 135 uint_8 k; 113 136 uint_4 i,j; double s; … … 143 166 cout<<"------------ Inversion"<<endl; 144 167 //InvA = Inverse(A); 145 InvA = IdentityMatrix(1.,N); TYPE det = GausPiv(A,InvA); cout<<"Det = "<<det<<endl; 168 InvA = IdentityMatrix(1.,N); 169 if(timok) PrtTim("--- End of filling ---"); 170 TYPE det = GausPiv(A,InvA,detok); 171 if(timok) PrtTim("--- End of GausPiv ---"); 172 cout<<"Det = "<<det<<endl; 146 173 cout<<"------------ TMatrix InvA = A^(-1):"<<endl; 147 174 if(nprline>0) {cout<<InvA; cout<<endl<<endl;} … … 154 181 155 182 //-- Check 156 doublevmax=-1.;183 vmax=-1.; 157 184 for(i=0;i<N;i++) { 158 185 double absv = ABS_VAL( 1. - AiA(i,i) ); … … 175 202 cout<<endl<<"LAPACK Cross-Check"<<endl; 176 203 InvA = IdentityMatrix(1.,N); 204 if(timok) PrtTim("--- End of check ---"); 177 205 LapackLinSolve(Adum,InvA); 206 if(timok) PrtTim("--- End of LapackLinSolve ---"); 178 207 AiA = A * InvA; 179 208 vmax=-1.; … … 193 222 #endif 194 223 224 if(timok) PrtTim("--- End of Job ---"); 195 225 exit(0); 196 226 }
Note:
See TracChangeset
for help on using the changeset viewer.