Changeset 1100 in Sophya
- Timestamp:
- Jul 26, 2000, 6:31:34 PM (25 years ago)
- Location:
- trunk/SophyaProg/Tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/arrt.cc
r857 r1100 21 21 22 22 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" 24 24 << " a: Simple Array Test w: a+ PPersist Test (FIO_TArray<T>) \n" 25 25 << " m: Matrix and Vector Test \n" … … 160 160 // sub array extraction, Range(2,4) : starting position=2 , End=4 161 161 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; 163 163 // we set the sub-array to zero, this should reflect in the original array 164 164 // sub-arrays share their data with parent array -
trunk/SophyaProg/Tests/carrt.cc
r1083 r1100 8 8 #include "timing.h" 9 9 10 static int test_ac(); 11 static int test_oso(int r, int c); 12 static int test_odo(int r, int c); 13 14 static int prtlev = 0; 15 static int nprt = 0; 16 17 template <class T> 18 void 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 10 28 int main(int narg, char* arg[]) 11 29 { … … 13 31 SophyaInit(); 14 32 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 "); 15 53 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 70 int test_ac() 71 { 16 72 cout << "\n -----> Testing TArray Conversion <---- " << endl; 17 73 TArray<int_4> ia(7,5); … … 19 75 TArray<r_4> ra(7,5); 20 76 ra = ia; 77 cout << " ra = ia(= Sequence(10., 2.)) = \n " << ra << endl; 21 78 cout << ra << endl; 22 79 TArray<r_4> rb(5,3); … … 36 93 cout << " Trying TMatrix<int_4> mx3(3,5); mx3 = rc; ?? " << endl; 37 94 mx3 = rc; 95 return(0); 96 } 97 98 int 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; 38 116 } 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 137 int 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); 45 175 46 176 } -
trunk/SophyaProg/Tests/lpk.cc
r857 r1100 13 13 void lpk_tarr(int n); 14 14 void lpk_tmtx(int n); 15 15 16 16 17 int main(int narg, char* arg[]) … … 76 77 77 78 cout << "\n Calling LapackLinSolve(a,b) .... " << endl; 79 PrtTim(" Calling LapackLinSolve(a,b) "); 78 80 LapackLinSolve(a,b); 81 PrtTim(" End LapackLinSolve(a,b) "); 79 82 80 83 cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl;
Note:
See TracChangeset
for help on using the changeset viewer.