Changeset 789 in Sophya for trunk/SophyaProg/Tests/arrt.cc
- Timestamp:
- Mar 20, 2000, 7:24:31 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/arrt.cc
r786 r789 7 7 #include "tarrinit.h" 8 8 #include "tarray.h" 9 #include "matharr.h" 9 10 #include "timing.h" 10 11 … … 25 26 try { 26 27 cout << "\n -----> Testing TArray <---- " << endl; 28 // We create a integer array SizeX=7, SizeY=5 27 29 TArray<int_4> ia(7,5); 30 // We fill it with a sequence of numbers starting at 10., with step = 2. 28 31 ia = Sequence(10., 2.); 29 32 cout << " ----- matrix IA = \n " << ia << endl; 30 // Extraction de sous tableau 33 // sub array extraction, Range(2,3) : starting position=2 , size=3 31 34 TArray<int_4> ic = ia(Range(2,3),Range(1,2)); 32 35 cout << " ----- matrix IC IA(Range(2,3),Range(1,2)) = \n " << ic << endl; 36 // we set the sub-array to zero, this should reflect in the original array 37 // sub-arrays share their data with parent array 33 38 ic = 0; 34 39 cout << " ----- matrix IC Apres (=0) = \n " << ic << endl; … … 37 42 cout << " :::: 3 Dim arrays ::::: " << endl; 38 43 TArray<int_4>::SetMaxPrint(1000); 44 // Creating 3-dim array (X=8 x Y=7 x Z=2) , filling it with 5 39 45 TArray<int_4> ib(8,7,2); 40 46 ib = 5; 41 47 cout << " ----- matrix IB = \n " << ib << endl; 48 // Sub array extraction X from 1 , size 4 - Y from 2 , size 3 , in Z default, from 0, size 1 49 // we multiply this sub-array elements by 3 42 50 ib(Range(1,4),Range(2,3)) *= 3; 43 51 cout << " -- matrix IB , Apres ib(Range(1,3),Range(2,1))*=3 : " << endl; 44 52 cout << ib; 53 54 // Creating a double array X=5 x Y=2 55 TArray<r_4> fa(5,2); 56 // fill it up with a sequence of 0. to 1. 57 fa = Sequence(0.,1./(5*2)); 58 cout << " ------ TArray<r_4> fa(5,2) = \n" << fa << endl; 59 // Create a new array from the original array , multiplying it by 2*Pi 60 TArray<r_4> fa2 = fa*(float)(2.*M_PI); 61 cout << " ------ TArray<r_4> fa2=fa*2*Pi = \n" << fa2 << endl; 62 // Compute sin(fa2) cos(fa2) 63 cout << " ------ sin(fa2=fa*2*Pi) = \n" << sin(fa2) << endl; 64 cout << " ------ cos(fa2=fa*2*Pi) = \n" << cos(fa2) << endl; 45 65 } 46 66 catch (PThrowable exc) {
Note:
See TracChangeset
for help on using the changeset viewer.