// Test de l'inversion de matrice (cmv 14/04/00) #include "machdefs.h" #include #include #include #include #include #include #include "ntoolsinit.h" #include "pexceptions.h" #include "array.h" #include "srandgen.h" // if defined COMPLEX , if not REAL #define COMPLEX // if defined 32 bits precision, if not 64 bits // #define PRECIS32 #if defined(COMPLEX) #define ABS_VAL(_x_) sqrt((double)(_x_.real()*_x_.real() + _x_.imag()*_x_.imag())) #if defined(PRECIS32) #define TYPE complex #else #define TYPE complex #endif #else #define ABS_VAL(_x_) fabs((double)_x_) #if defined(PRECIS32) #define TYPE r_4 #else #define TYPE r_8 #endif #endif int main(int narg,char *arg[]) { //-------------------------------------------------------- // number of lines/columns int_4 N = 5; // scale of the value (if =1 values between -1 and 1) r_8 scale = 1.; // number of values change by +/- vbig int_4 nbig = N; r_8 vbig = 1000.; // Nombre de ligne de matrice a imprimer int_4 nprline = 10; //-------------------------------------------------------- //-- Decodage arguments char c; while((c = getopt(narg,arg,"hv:l:")) != -1) { switch (c) { case 'v' : sscanf(optarg,"%d,%lf,%d,%lf",&N,&scale,&nbig,&vbig); break; case 'l' : sscanf(optarg,"%d",&nprline); break; case 'h' : cout<<"tsttminv [-h] [-v N,scale,nbig,vbig] [-l nprline]"< A(N,N); TMatrix< TYPE > InvA(N,N); TMatrix< TYPE > AiA(N,N); TMatrix< TYPE > B(N,N); TMatrix< TYPE > C(N,N); A.Show(); //-- Mise a zero A = (TYPE) 0; InvA = (TYPE) 0; AiA = (TYPE) 0; B = (TYPE) 0; C = (TYPE) 0; BaseArray::SetMaxPrint(nprline*N,0); //-- Fill matrices uint_8 k; int_4 i,j; double s; A = Sequence(RandomSequence(RandomSequence::Flat,0.,1.)); if(nbig>0) for(i=0;i=N*N) k--; s=(drand01()>0.5)?1.:-1.; A[k] += (TYPE) s*vbig;} A *= (TYPE) scale; #if defined(COMPLEX) B = Sequence(RandomSequence(RandomSequence::Flat,0.,1.)); if(nbig>0) for(i=0;i=N*N) k--; s=(drand01()>0.5)?1.:-1.; B[k] += (TYPE) s*vbig;} B *= (TYPE) scale; A += TYPE(0.,1.)*B; #endif //-- Print matrice A cout<<"------------ TMatrix A :"<0) {cout<0) {cout<0) {cout< vmax ) vmax = absv; if( absv < vmin ) vmin = absv; k++; } cout<<"Limites sur la diagonale " <