Changeset 1968 in Sophya
- Timestamp:
- Apr 26, 2002, 7:12:37 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Examples/arr1.icc
r1967 r1968 1 // We create a integer array SizeX=7, SizeY=5 2 TArray<int_4> ia(7,5); 3 // We fill it with a sequence of numbers starting at 10., with step = 2. 4 ia = RegularSequence(10., 2.); 5 cout << " ----- Array IA = \n " << ia << endl; 6 TArray<int_4> ib = ia(Range(0,3), Range(3,4), Range(0)); 7 cout << " ----- Array IB IA(Range(0,3), Range(3,2)) = \n" << ib << endl; 8 // sub array extraction, Range(2,4) : starting position=2 , End=4 9 TArray<int_4> ic = ia(Range(2,3),Range(1,3),Range(0)); 10 cout << " ----- Array IC IA(Range(2,3),Range(1,3)) = \n " << ic << endl; 11 // we set the sub-array to zero, this should reflect in the original array 12 // sub-arrays share their data with parent array 13 ic = 0; 14 cout << " ----- Array IC Apres (=0) = \n " << ic << endl; 15 cout << " ----- Array IB Apres IC=0 = \n " << ib << endl; 16 cout << " ----- Array IA Apres IC=0 = \n " << ia << endl; 17 cout << " >>>>>> Writing in arrt.ppf <<<<<<< " << endl; 18 POutPersist pos("arrt.ppf"); 19 // We write the three arrays in the stream 20 pos << ia << ib << ic; 1 // Fichier arr1.icc 2 // Exemple d'utilisation de tableaux 3 // Appel: runcxx -f arr1.icc 4 // Creation , remplissage d'une matrice 5 TMatrix<r_4> ma(7,9); 6 ma = RegularSequence(0.1, 0.05); 7 cout << "\n arr1.icc: ma = " << ma << endl; 8 float min, max; 9 // Utilisation des sous-tableaux 10 ma(Range(2,4), Range(4,7)) = M_PI; 11 cout << "\n Apres ma(Range(2,4), Range(4,7)) = " << ma << endl; 12 // Appel de methodes 13 ma.MinMax(min, max); 14 cout << " MinMax(ma) : min= " << min << " max= " << max << endl; 15 TMatrix<r_4> sma = Sin(ma); 16 cout << "\n test pour runcxx - sma = Sin(ma)= " << sma << endl; 17 sma.MinMax(min, max); 18 cout << " MinMax(sma) : min= " << min << " max= " << max << endl; 21 19 20 // Vector , matrix multiplication 21 Vector v1(5); 22 v1 = 12.; 23 Vector v2(5); 24 v2 = 14; 25 Matrix m = v2*v1.Transpose(); 26 cout << " m= v2*v1.Transpose() : " << m; 27 // Computing the scalar product 28 cout << " v1.v2 = " << (v1.Transpose()*v2).toScalar() << endl;
Note:
See TracChangeset
for help on using the changeset viewer.