Changeset 2578 in Sophya for trunk/SophyaProg/Tests
- Timestamp:
- Jul 29, 2004, 2:33:39 PM (21 years ago)
- Location:
- trunk/SophyaProg/Tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/arrt.cc
r2322 r2578 14 14 static void tstmtx(int n); 15 15 void _ZZ_TestTMatrixRC_YY_(TMatrix<r_8> & m); 16 17 static int prtlev = 1; 16 18 17 19 int main(int narg, char* arg[]) … … 34 36 int n = 5; 35 37 if (narg > 2) n = atoi(arg[2]); 36 uint_4 prtlev = 1;37 38 uint_4 nprt = 50; 38 39 if (narg > 3) prtlev = atoi(arg[3]); … … 75 76 cout << "\n :::::: Testing TMatrix - TVector :::::: " << endl; 76 77 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; 78 80 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; 80 83 TMatrix<r_4> mb(2,3); 81 84 mb = 50.; 82 85 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; 84 88 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 } 87 93 88 94 TMatrix<int_4> ima(3,10); 89 95 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 } 92 100 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 } 95 105 TVector<int_4> vlig; 96 106 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; 98 109 99 110 TMatrix<int_4> imb(3,10); 100 111 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; 102 114 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; 104 117 TMatrix<int_4> imd(3,10); 105 118 TMatrix<int_4> imd2(3,10); … … 107 120 imd *= 2; 108 121 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; 111 125 imb -= imd; 112 126 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; 115 130 TVector<r_4> va(16, BaseArray::RowVector); 116 131 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; 118 134 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; 120 137 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; 122 140 123 141 TMatrix<r_4> esm(3,5); … … 128 146 31 , 32 , 33, 34, 35 ; 129 147 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; 132 151 r_4 emin,emax,esum,eprod,esumx2; 133 152 esm.MinMax(emin, emax); … … 136 155 esumx2 = esm.SumX2(); 137 156 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; 140 160 141 161 cout << "\n :::::: Testing Matrix operations :::::: " << endl; … … 150 170 ra = es ; 151 171 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 } 156 177 157 178 cout << "\n ::::::: Testing Matrix Inversion ::::::: " << endl; 158 179 SimpleMatrixOperation<r_4> smr; 159 180 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 } 163 185 Matrix a(n,n); 164 186 … … 167 189 // for(int j=0; j<n; j++) a(j,i) = GauRnd(0., 1.); 168 190 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; 170 193 Vector x(n); 171 194 x = RegularSequence(1.,3.); 172 195 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 } 175 200 SimpleMatrixOperation<r_8> smo; 176 201 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 } 181 208 } 182 209 -
trunk/SophyaProg/Tests/carrt.cc
r2568 r2578 55 55 if (narg > 5) nprt = atoi(arg[5]); 56 56 57 BaseArray::SetMaxPrint(nprt , prtlev);57 BaseArray::SetMaxPrint(nprt); 58 58 int rc = 0; 59 59 PrtTim(" Start of Test "); … … 227 227 else cout << "(7) OK Test C=A+2*B OK " << endl; 228 228 229 c = (a*4+1).DivElt(b);229 (a*4+1).DivElt(b,c); 230 230 if (prtlev > 0) cout << "(8) C = (A*4+1)/B = " << c << endl; 231 231 getMinMax(c, min, max); … … 347 347 else cout << "(7) OK Test C=A+2*B OK " << endl; 348 348 349 c = (a*4.0f+5.5f).DivElt(b);349 (a*4.0f+5.5f).DivElt(b,c); 350 350 if (prtlev > 0) cout << "(8) C = (A*4+12)/B = " << c << endl; 351 351 getMinMax(c, min, max);
Note:
See TracChangeset
for help on using the changeset viewer.