Changeset 1561 in Sophya for trunk/SophyaProg
- Timestamp:
- Jul 3, 2001, 5:42:50 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/arrt.cc
r1519 r1561 3 3 #include <math.h> 4 4 #include <iostream.h> 5 #include <fstream.h> 5 6 6 7 #include "tarrinit.h" … … 9 10 10 11 static void tstarr(bool tio); 12 static void tstasciiio(); 11 13 static void tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic); 12 14 static void tstmtx(int n); … … 24 26 << " a: Simple Array Test w: a+ PPersist Test (FIO_TArray<T>) \n" 25 27 << " m: Matrix and Vector Test \n" 28 << " ascio: Test of ascii I/O \n" 26 29 << " z: Appel_ZZ_TestTMatrixRC_YY_ " << endl; 27 30 exit(0); 28 31 } 29 32 30 int opt = *(arg[1]);33 string opt = arg[1]; 31 34 int n = 5; 32 35 if (narg > 2) n = atoi(arg[2]); … … 39 42 40 43 try { 41 if ((opt == 'w') || (opt == 'a')) tstarr((opt=='w')); 42 else if (opt == 'z') { 44 if (opt == "w") tstarr(true); 45 else if (opt == "a") tstarr(false); 46 else if (opt == "z") { 43 47 if (n<5) n = 5; 44 48 TMatrix<r_8> tza(n,n+3); … … 48 52 _ZZ_TestTMatrixRC_YY_(tza2); 49 53 } 50 else tstmtx(n); 54 else if (opt == "m") tstmtx(n); 55 else if (opt == "ascio") tstasciiio(); 56 else { 57 cout << " arrt/Error : unknown option ! " << endl; 58 } 51 59 } 52 60 catch (PThrowable exc) { … … 287 295 } 288 296 289 290 } 297 } 298 299 300 void tstasciiio() 301 { 302 303 cout << "\n -----> Testing EnumeratedSequence/TArray ASCII I/O <---- " << endl; 304 305 EnumeratedSequence ess; 306 int nbad; 307 ess.Append("56.5 (1.,-1.) 4 8 16", nbad); 308 cout << " --- ess.Append(\"56.5 (1.,-1.) 4 8 16\", nbad) : ess=" << endl; 309 cout << ess; 310 311 EnumeratedSequence ess2; 312 ess2.Append("56.5 (-3.14, 12) 'Hello' 4. 8.565432 12 32 3.1415e-6", nbad); 313 cout << " --- ess2.Append(...) ess2=" << endl; 314 cout << ess2; 315 cout << " --- ess2.Append(...) (2) ess2=" << endl; 316 ess2.Append("(2.7, -8) Bonjour ByeBye 'Comment ca va ?' 64 64.7 128 1.28 25.6e3", 317 nbad); 318 cout << ess2; 319 320 Matrix A(4,6); 321 A = RegularSequence(0.5, 0.2); 322 cout << " Matrix A(4,6); A=RegularSequence(0.5, 0.2) : " << endl; 323 cout << A ; 324 325 char * flnm = "arr_ascii.txt"; 326 { 327 cout << " Writing A to file " << flnm << endl; 328 ofstream ofs(flnm); 329 A.WriteASCII(ofs); 330 } 331 332 Matrix B; 333 sa_size_t nr, nc; 334 { 335 ifstream ifs(flnm); 336 B.ReadASCII(ifs,nr,nc); 337 } 338 339 cout << " Matrix B; B.ReadASCII() from file " << flnm << endl; 340 cout << B ; 341 342 Vector C; 343 { 344 ifstream ifs(flnm); 345 C.ReadASCII(ifs,nr,nc); 346 } 347 cout << " Vector C; C.ReadASCII() from file " << flnm << endl; 348 cout << " C.Transpose()= " << C.Transpose() ; 349 350 TVector<int_4> IC; 351 { 352 ifstream ifs(flnm); 353 IC.ReadASCII(ifs,nr,nc); 354 } 355 cout << " TVector<int_4> IC; IC.ReadASCII() from file " << flnm << endl; 356 cout << " IC.Transpose()= " << IC.Transpose() ; 357 358 TArray<r_4> D(4,6,2); 359 { 360 ifstream ifs(flnm); 361 D.ReadASCII(ifs,nr,nc); 362 } 363 cout << " TArray<r_4> D(4,6,2); D.ReadASCII() from file " << flnm << endl; 364 cout << D ; 365 366 }
Note:
See TracChangeset
for help on using the changeset viewer.