Changeset 807 in Sophya for trunk/SophyaProg/Tests/arrt.cc
- Timestamp:
- Apr 3, 2000, 7:44:06 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/arrt.cc
r789 r807 7 7 #include "tarrinit.h" 8 8 #include "tarray.h" 9 #include "fioarr.h" 9 10 #include "matharr.h" 10 11 #include "timing.h" 11 12 13 14 void tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic); 15 void tstmtx(); 12 16 13 17 int main(int narg, char* arg[]) … … 21 25 int i,j,k; 22 26 23 if (narg > 1) n = atoi(arg[1]); 27 bool tio = false; 28 if (narg > 1) tio = true; 24 29 25 26 30 try { 27 31 cout << "\n -----> Testing TArray <---- " << endl; … … 32 36 cout << " ----- matrix IA = \n " << ia << endl; 33 37 // sub array extraction, Range(2,3) : starting position=2 , size=3 34 TArray<int_4> ic = ia(Range(2,3),Range(1,2) );38 TArray<int_4> ic = ia(Range(2,3),Range(1,2),Range(0)); 35 39 cout << " ----- matrix IC IA(Range(2,3),Range(1,2)) = \n " << ic << endl; 36 40 // we set the sub-array to zero, this should reflect in the original array … … 48 52 // Sub array extraction X from 1 , size 4 - Y from 2 , size 3 , in Z default, from 0, size 1 49 53 // we multiply this sub-array elements by 3 50 ib(Range(1,4),Range(2,3) ) *= 3;54 ib(Range(1,4),Range(2,3), Range(0)) *= 3; 51 55 cout << " -- matrix IB , Apres ib(Range(1,3),Range(2,1))*=3 : " << endl; 52 56 cout << ib; … … 63 67 cout << " ------ sin(fa2=fa*2*Pi) = \n" << sin(fa2) << endl; 64 68 cout << " ------ cos(fa2=fa*2*Pi) = \n" << cos(fa2) << endl; 69 70 if (tio) tstioarr(ia, ib, ic); 71 65 72 } 66 73 catch (PThrowable exc) { … … 72 79 cout << " --------------- END of Programme -------------- " << endl; 73 80 } 81 82 void tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic) 83 { 84 cout << " ------ tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic) ---- " << endl; 85 { 86 cout << " >>>>>> Writing in arrt.ppf <<<<<<< " << endl; 87 POutPersist pos("arrt.ppf"); 88 // We write the three arrays in the stream 89 pos << ia << ib << ic; 90 cout << " >>>>>> Writing in arrtn.ppf with names <<<<<<<" << endl; 91 POutPersist posn("arrtn.ppf"); 92 string tag = "ArrIA"; 93 posn.PutObject(ia, tag); 94 tag = "ArrIB"; 95 posn.PutObject(ib, tag); 96 tag = "ArrIC"; 97 posn.PutObject(ic, tag); 98 } 99 100 { 101 cout << " >>>>>>> Reading from arrt.ppf <<<<< " << endl; 102 PInPersist pis("arrt.ppf"); 103 TArray<int_4> iaa, ibb, icc; 104 // We read the three arrays from the stream 105 pis >> iaa >> ibb >> icc; 106 cout << " ----- matrix IAA = \n " << iaa << endl; 107 cout << " ----- matrix IBB = \n " << ibb << endl; 108 cout << " ----- matrix ICC = \n " << icc << endl; 109 icc = 12; 110 cout << " ----- matrix ICC (=12) = \n " << icc << endl; 111 cout << " ----- matrix IAA (ICC=12) = \n " << iaa << endl; 112 } 113 114 { 115 cout << " >>>>>>> Reading from arrtn.ppf <<<<< " << endl; 116 PInPersist pis("arrtn.ppf"); 117 TArray<int_4> iaa, ibb, icc; 118 // We read the three arrays from the stream 119 string tag = "ArrIC"; 120 pis.GetObject(icc, tag); 121 tag = "ArrIB"; 122 pis.GetObject(ibb, tag); 123 tag = "ArrIA"; 124 pis.GetObject(iaa, tag); 125 126 cout << " ----- matrix IAAA = \n " << iaa << endl; 127 cout << " ----- matrix IBBB = \n " << ibb << endl; 128 cout << " ----- matrix ICCC = \n " << icc << endl; 129 icc = 68; 130 cout << " ----- matrix ICCC (=12) = \n " << icc << endl; 131 cout << " ----- matrix IAAA (ICC=12) = \n " << iaa << endl; 132 } 133 134 135 }
Note:
See TracChangeset
for help on using the changeset viewer.