Changeset 1100 in Sophya


Ignore:
Timestamp:
Jul 26, 2000, 6:31:34 PM (25 years ago)
Author:
ansari
Message:

Amelioration programmes test de tableaux - Reza 26/7/2000

Location:
trunk/SophyaProg/Tests
Files:
3 edited

Legend:

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

    r857 r1100  
    2121
    2222  if (narg < 2) {
    23     cout << " arrt - TArray<T> Test - Usage arrt a/p/m/z [size=5] [prtlev=1] [nprt=50]\n"
     23    cout << " arrt - TArray<T> Test - Usage arrt a/w/m/z [size=5] [prtlev=1] [nprt=50]\n"
    2424         << " a: Simple Array Test  w: a+ PPersist Test (FIO_TArray<T>) \n"
    2525         << " m: Matrix and Vector Test \n"
     
    160160  // sub array extraction, Range(2,4) : starting position=2 , End=4
    161161  TArray<int_4> ic = ia(Range(2,3),Range(1,3),Range(0));
    162   cout << " ----- Array IC IA(Range(2,4),Range(1,2)) = \n " << ic << endl;
     162  cout << " ----- Array IC IA(Range(2,3),Range(1,3)) = \n " << ic << endl;
    163163  // we set the sub-array to zero, this should reflect in the original array
    164164  // sub-arrays share their data with parent array
  • trunk/SophyaProg/Tests/carrt.cc

    r1083 r1100  
    88#include "timing.h"
    99
     10static int test_ac();
     11static int test_oso(int r, int c);
     12static int test_odo(int r, int c);
     13
     14static int prtlev = 0;
     15static int nprt = 0;
     16
     17template <class T>
     18void getMinMax(TArray<T>& a, T& min, T& max)
     19{
     20  min = a[0];
     21  max = a[0];
     22  for(uint_8 k=1; k<a.Size(); k++) {
     23    if (a[k]<min)  min = a[k];
     24    else if (a[k]>max)  max = a[k];
     25  }
     26}
     27
    1028int main(int narg, char* arg[])
    1129{
     
    1331  SophyaInit();
    1432  InitTim();   // Initializing the CPU timer
     33
     34  if (narg < 2) {
     35    cout << " carrt ac/oso/odo [NRow=5] [NCols=10] [prtlev=0] [nprtmax=100] \n"
     36         << "   ac : array conversion test   \n"
     37         << "   oso : operation same memory organisation \n"
     38         << "   odo : operation different memory organisation \n" << endl;
     39    exit(0);
     40  }
     41
     42  string opt = arg[1];
     43  int nr = 5;
     44  int nc = 10;
     45  if (narg > 2) nr = atoi(arg[2]);
     46  if (narg > 3) nc = atoi(arg[3]);
     47  if (narg > 4) prtlev = atoi(arg[4]);
     48  if (narg > 5) nprt = atoi(arg[5]);
     49
     50  BaseArray::SetMaxPrint(nprt, prtlev);
     51 
     52  PrtTim(" Start of Test ");
    1553  try {
     54    if (opt == "ac") test_ac();
     55    else if (opt == "oso") test_oso(nr, nc);
     56    else if (opt == "odo") test_odo(nr, nc);
     57  }
     58  catch (PThrowable & exc) {
     59    cerr << " catched Exception " << exc.Msg() << endl;
     60  } 
     61  catch (...) {
     62    cerr << " catched unknown (...) exception " << endl;
     63  } 
     64
     65  PrtTim(" End of Test ");
     66
     67}
     68
     69
     70int test_ac()
     71{
    1672    cout << "\n -----> Testing TArray Conversion <---- " << endl;
    1773     TArray<int_4> ia(7,5);   
     
    1975     TArray<r_4> ra(7,5);   
    2076     ra = ia;
     77     cout << " ra = ia(= Sequence(10., 2.)) = \n " << ra << endl;
    2178     cout << ra << endl; 
    2279     TArray<r_4> rb(5,3);
     
    3693     cout << " Trying      TMatrix<int_4> mx3(3,5);  mx3 = rc; ?? " << endl;
    3794     mx3 = rc;
     95     return(0);
     96}
     97
     98int test_oso(int nr, int nc)
     99{
     100  cout << "\n -----> Testing TArray operation TArray<int_4>(nx=" << nr << ",ny="
     101       << nc << " )" << endl;
     102
     103  int rc = 0;
     104  int min,max;
     105
     106  TArray<int_4> a(nr,nc);
     107  a = 20;
     108  TArray<int_4> b(nr,nc);
     109  b = 9;
     110  TArray<int_4> c = a-2*b;
     111
     112  if (prtlev > 0) {
     113    cout << " A = \n " << a << endl;
     114    cout << " B = \n " << b << endl;
     115    cout << " C = A-2*B= \n " << c << endl;
    38116  }
    39   catch (PThrowable & exc) {
    40     cerr << " catched Exception " << exc.Msg() << endl;
    41   } 
    42   catch (...) {
    43     cerr << " catched unknown (...) exception " << endl;
    44   } 
     117
     118  getMinMax(c, min, max);
     119  if ((min != 2) || (max != 2)) {
     120    cout << "!!! ERROR Test C=A+2*B  Min=" << min << " Max=" << max << endl;
     121    rc += 1;
     122  }
     123  else cout << " OK   Test C=A+2*B  OK " << endl;
     124
     125  c = (a*4+1).DivElt(b);
     126  if (prtlev > 0) cout << " C = (A*4+1)/B = \n" << c << endl;
     127  getMinMax(c, min, max);
     128  if ((min != 9) || (max != 9)) {
     129    cout << "!!! ERROR Test C = (A*4+1)/B  Min=" << min << " Max=" << max << endl;
     130    rc += 2;
     131  }
     132  else cout << " OK   Test C = (A*4+1)/B  OK " << endl;
     133 
     134  return(rc);
     135}
     136
     137int test_odo(int nr, int nc)
     138{
     139  cout << "\n -----> Testing TMatrix operation TMatrix<r_4>(nr=" << nr << ",nc="
     140       << nc << " )" << endl;
     141  cout << "   A CMemoryMapping  - B FortranMemoryMapping " << endl;
     142
     143  r_4 rc = 0;
     144  r_4 min,max;
     145
     146  TMatrix<r_4> a(nr,nc,BaseArray::CMemoryMapping);
     147  a = 20;
     148  TMatrix<r_4> b(nr,nc,BaseArray::FortranMemoryMapping);
     149  b = 9;
     150  TMatrix<r_4> c(nr,nc,BaseArray::CMemoryMapping);
     151
     152  if (prtlev > 0) {
     153    cout << " A = \n " << a << endl;
     154    cout << " B = \n " << b << endl;
     155  }
     156  c = a-(b*2.0f);
     157  if (prtlev > 0) cout << " C = A-2*B= \n " << c << endl;
     158
     159  getMinMax(c, min, max);
     160  if ((fabs(min-2.) > 0.0001) || (fabs(max-2.) > 0.0001)) {
     161    cout << "!!! ERROR Test C=A+2*B  Min=" << min << " Max=" << max << endl;
     162    rc += 1;
     163  }
     164  else cout << " OK   Test C=A+2*B  OK " << endl;
     165
     166  c = (a*4.0f+5.5f).DivElt(b);
     167  if (prtlev > 0) cout << " C = (A*4+12)/B = \n" << c << endl;
     168  getMinMax(c, min, max);
     169  if ((fabs(min-9.5) > 0.0001) || (fabs(max-9.5) > 0.0001)) {
     170    cout << "!!! ERROR Test C = (A*4+12)/B  Min=" << min << " Max=" << max << endl;
     171    rc += 2;
     172  }
     173  else cout << " OK   Test C = (A*4+12)/B  OK " << endl;
     174  return(rc);
    45175
    46176}
  • trunk/SophyaProg/Tests/lpk.cc

    r857 r1100  
    1313void lpk_tarr(int n);
    1414void lpk_tmtx(int n);
     15
    1516
    1617int main(int narg, char* arg[])
     
    7677
    7778  cout << "\n   Calling LapackLinSolve(a,b) .... " << endl;
     79  PrtTim(" Calling LapackLinSolve(a,b) ");
    7880  LapackLinSolve(a,b);
     81  PrtTim(" End LapackLinSolve(a,b) ");
    7982
    8083  cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl;
Note: See TracChangeset for help on using the changeset viewer.