Changeset 2578 in Sophya for trunk/SophyaProg/Tests


Ignore:
Timestamp:
Jul 29, 2004, 2:33:39 PM (21 years ago)
Author:
ansari
Message:

Adaptation carrt.cc suites modifs methodes Add/Sub/Mul/DivElt(.., res) de TArray - Reza 29 Juillet 2004

Location:
trunk/SophyaProg/Tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/arrt.cc

    r2322 r2578  
    1414static void tstmtx(int n);
    1515void _ZZ_TestTMatrixRC_YY_(TMatrix<r_8> & m);
     16
     17static int prtlev = 1;
    1618
    1719int main(int narg, char* arg[])
     
    3436  int n = 5;
    3537  if (narg > 2) n = atoi(arg[2]);
    36   uint_4 prtlev = 1;
    3738  uint_4 nprt = 50;
    3839  if (narg > 3) prtlev = atoi(arg[3]);
     
    7576  cout << "\n ::::::  Testing TMatrix - TVector ::::::  " << endl; 
    7677  TMatrix<r_4> sma1 = ma(Range(1,2), Range(2,4));
    77   cout << " ----- Matrix ma = \n " << ma << endl;
     78  if (prtlev > 0)
     79    cout << " ----- Matrix ma = \n " << ma << endl;
    7880  sma1 = 3.14;
    79   cout << " ----- Matrix ma (Avec sma1=ma(Range(1,2), Range(2,3))=3.14) = \n " << ma << endl;
     81  if (prtlev > 0)
     82    cout << " ----- Matrix ma (Avec sma1=ma(Range(1,2), Range(2,3))=3.14) = \n " << ma << endl;
    8083  TMatrix<r_4> mb(2,3);
    8184  mb = 50.;
    8285  TMatrix<r_4> mc = mb+sma1;
    83   cout << " ----- Matrix mc = mb(=50.)+sma1(=3.14) = " << mc << endl;
     86  if (prtlev > 0)
     87    cout << " ----- Matrix mc = mb(=50.)+sma1(=3.14) = " << mc << endl;
    8488  TMatrix<r_4> md = (float)100+mc;
    85   cout << " ----- Matrix md=100.+mc = " << md << endl;
    86   cout << " ----- Matrix md-50 = " << md-(float)50. << endl;
     89  if (prtlev > 0) {
     90    cout << " ----- Matrix md=100.+mc = " << md << endl;
     91    cout << " ----- Matrix md-50 = " << md-(float)50. << endl;
     92  }
    8793
    8894  TMatrix<int_4> ima(3,10);
    8995  ima = RegularSequence(0.01,1.);
    90   cout << " ----- Matrix ima(3,10) = RegularSequence(0.01,1.) = " << ima << endl;
    91   cout << " ----- Matrix  ima.Column(3) = \n" << ima.Column(3) << endl;
     96  if (prtlev > 0) {
     97    cout << " ----- Matrix ima(3,10) = RegularSequence(0.01,1.) = " << ima << endl;
     98    cout << " ----- Matrix  ima.Column(3) = \n" << ima.Column(3) << endl;
     99  }
    92100  TVector<int_4> vcol = ima.Column(7);
    93   cout << " ----- Vector  vcol=ima.Column(7) = \n" << vcol << endl;
    94   cout << " ----- Matrix  ima.Row(0) = \n" << ima.Row(0) << endl;
     101  if (prtlev > 0) {
     102    cout << " ----- Vector  vcol=ima.Column(7) = \n" << vcol << endl;
     103    cout << " ----- Matrix  ima.Row(0) = \n" << ima.Row(0) << endl;
     104  }
    95105  TVector<int_4> vlig;
    96106  vlig = ima.Row(1);
    97   cout << " ----- Vector  vlig=ima.Row(1) = \n" << vlig << endl;
     107  if (prtlev > 0)
     108    cout << " ----- Vector  vlig=ima.Row(1) = \n" << vlig << endl;
    98109
    99110  TMatrix<int_4> imb(3,10);
    100111  imb = RegularSequence(100.01,10.);
    101   cout << " ----- Matrix imb(3,10) = RegularSequence(100.01,10.) = " << imb << endl;
     112  if (prtlev > 0)
     113    cout << " ----- Matrix imb(3,10) = RegularSequence(100.01,10.) = " << imb << endl;
    102114  TMatrix<int_4> imc = ima+imb;
    103   cout << " ----- Matrix imc=ima+imb = " << imc << endl;
     115  if (prtlev > 0)
     116    cout << " ----- Matrix imc=ima+imb = " << imc << endl;
    104117  TMatrix<int_4> imd(3,10);
    105118  TMatrix<int_4> imd2(3,10);
     
    107120  imd *= 2;
    108121  imd2 = 2;
    109   imd.MulElt(imd2);
    110   cout << " ----- Matrix imd (? = 100) " << imd << endl;
     122  imd.MulElt(imd2,imd);
     123  if (prtlev > 0)
     124    cout << " ----- Matrix imd (? = 100) " << imd << endl;
    111125  imb -= imd;
    112126  imc -= imd;
    113   cout << " ----- Matrix ((imc-=imd)-(imb-=imd))-ima (== 0 ?) "
    114        << (imc-imb)-ima << endl;
     127  if (prtlev > 0)
     128    cout << " ----- Matrix ((imc-=imd)-(imb-=imd))-ima (== 0 ?) "
     129         << (imc-imb)-ima << endl;
    115130  TVector<r_4> va(16, BaseArray::RowVector);
    116131  va = RegularSequence(0.,1.);
    117   cout << " ----- Vector va = RegularSequence(0.,1.) = " << va << endl;
     132  if (prtlev > 0)
     133    cout << " ----- Vector va = RegularSequence(0.,1.) = " << va << endl;
    118134  va(Range(2,0,6,2)) *= 10.;
    119   cout << " ----- Vector va apres va(Range(2,0,6,2)) *= 10. " << va << endl;
     135  if (prtlev > 0)
     136    cout << " ----- Vector va apres va(Range(2,0,6,2)) *= 10. " << va << endl;
    120137  va(Range(0,5)) += 100.;
    121   cout << " ----- Vector va apres va(Range(0,6)) += 100. " << va << endl;
     138  if (prtlev > 0)
     139    cout << " ----- Vector va apres va(Range(0,6)) += 100. " << va << endl;
    122140
    123141  TMatrix<r_4> esm(3,5);
     
    128146         31 , 32 , 33, 34, 35  ; 
    129147  esm = ess;
    130   cout << "\n TMatrix<r_4> esm(3,5) = EnumeratedSequence(), 11 , 12 , 13, 14, 15 ... "
    131        << esm << endl;
     148  if (prtlev > 0)
     149    cout << "\n TMatrix<r_4> esm(3,5) = EnumeratedSequence(), 11 , 12 , 13, 14, 15 ... "
     150         << esm << endl;
    132151  r_4 emin,emax,esum,eprod,esumx2;
    133152  esm.MinMax(emin, emax); 
     
    136155  esumx2 = esm.SumX2();
    137156
    138   cout << " Min= " << emin << "  Max= " << emax
    139        << " Sum= " << esum << " Prod=" << eprod << " SumX2=" << esumx2 << endl;
     157  if (prtlev > 0)
     158    cout << " Min= " << emin << "  Max= " << emax
     159         << " Sum= " << esum << " Prod=" << eprod << " SumX2=" << esumx2 << endl;
    140160
    141161  cout << "\n :::::: Testing Matrix operations :::::: " << endl;
     
    150170  ra = es ;
    151171 
    152   cout << " ----- Matrix ra = \n " << ra << endl;
    153   cout << " ----- Matrix ira = \n " << ira << endl;
    154   cout << " ----- Matrix ira*ra = (= Identity ?) " << ira*ra << endl;
    155 
     172  if (prtlev > 0) {
     173    cout << " ----- Matrix ra = \n " << ra << endl;
     174    cout << " ----- Matrix ira = \n " << ira << endl;
     175    cout << " ----- Matrix ira*ra = (= Identity ?) " << ira*ra << endl;
     176  }
    156177
    157178  cout << "\n ::::::: Testing Matrix Inversion ::::::: " << endl;
    158179  SimpleMatrixOperation<r_4> smr;
    159180  TMatrix<r_4> cira = smr.Inverse(ra);
    160   cout << " ----- Matrix Inverse(ra) =  " << cira << endl;
    161   cout << " ----- ira-Inverse(ra) = " << ira-cira << endl;
    162 
     181  if (prtlev > 0) {
     182    cout << " ----- Matrix Inverse(ra) =  " << cira << endl;
     183    cout << " ----- ira-Inverse(ra) = " << ira-cira << endl;
     184  }
    163185  Matrix a(n,n);
    164186
     
    167189  //    for(int j=0; j<n; j++)  a(j,i) = GauRnd(0., 1.);
    168190  a = RandomSequence(RandomSequence::Gaussian, 0., 2.5);
    169   cout << " ----- Matrix a=RandomSequence(RandomSequence::Gaussian, 0., 2.5) = \n " << a << endl;
     191  if (prtlev > 0)
     192    cout << " ----- Matrix a=RandomSequence(RandomSequence::Gaussian, 0., 2.5) = \n " << a << endl;
    170193  Vector x(n);
    171194  x = RegularSequence(1.,3.);
    172195  Vector b = a*x;
    173   cout << " ----- Vector x = \n " << x << endl;
    174   cout << " ----- Vector b = a*x = \n " << b << endl;
     196  if (prtlev > 0) {
     197    cout << " ----- Vector x = \n " << x << endl;
     198    cout << " ----- Vector b = a*x = \n " << b << endl;
     199  }
    175200  SimpleMatrixOperation<r_8> smo;
    176201  Matrix inva = smo.Inverse(a);
    177   cout << " ----- Matrix Inverse(a) = \n " << inva << endl;
    178   cout << " ----- Matrix a*Inverse(a) = \n " << inva*a << endl;
    179   cout << " ----- Matrix Inverse(a)*b (=Inv(a)*a*x) = \n " << inva*b << endl;
    180   cout << " ----- Matrix x-Inverse(a)*b = (=0 ?)\n " << x-inva*b << endl;
     202  if (prtlev > 0) {
     203    cout << " ----- Matrix Inverse(a) = \n " << inva << endl;
     204    cout << " ----- Matrix a*Inverse(a) = \n " << inva*a << endl;
     205    cout << " ----- Matrix Inverse(a)*b (=Inv(a)*a*x) = \n " << inva*b << endl;
     206    cout << " ----- Matrix x-Inverse(a)*b = (=0 ?)\n " << x-inva*b << endl;
     207  }
    181208}
    182209
  • trunk/SophyaProg/Tests/carrt.cc

    r2568 r2578  
    5555  if (narg > 5) nprt = atoi(arg[5]);
    5656
    57   BaseArray::SetMaxPrint(nprt, prtlev);
     57  BaseArray::SetMaxPrint(nprt);
    5858  int rc = 0;
    5959  PrtTim(" Start of Test ");
     
    227227  else cout << "(7) OK   Test C=A+2*B  OK " << endl;
    228228
    229   c = (a*4+1).DivElt(b);
     229  (a*4+1).DivElt(b,c);
    230230  if (prtlev > 0) cout << "(8) C = (A*4+1)/B = " << c << endl;
    231231  getMinMax(c, min, max);
     
    347347  else cout << "(7) OK   Test C=A+2*B  OK " << endl;
    348348
    349   c = (a*4.0f+5.5f).DivElt(b);
     349  (a*4.0f+5.5f).DivElt(b,c);
    350350  if (prtlev > 0) cout << "(8) C = (A*4+12)/B = " << c << endl;
    351351  getMinMax(c, min, max);
Note: See TracChangeset for help on using the changeset viewer.