Changeset 789 in Sophya


Ignore:
Timestamp:
Mar 20, 2000, 7:24:31 PM (26 years ago)
Author:
ansari
Message:

Amelioration, correction prg tests array Reza 20/3/2000

Location:
trunk/SophyaProg/Tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/arrt.cc

    r786 r789  
    77#include "tarrinit.h"
    88#include "tarray.h"
     9#include "matharr.h"
    910#include "timing.h"
    1011
     
    2526  try {
    2627  cout << "\n -----> Testing TArray <---- " << endl; 
     28  // We create a integer array SizeX=7, SizeY=5
    2729  TArray<int_4> ia(7,5);
     30  // We fill it with a sequence of numbers starting at 10., with step = 2.
    2831  ia = Sequence(10., 2.);
    2932  cout << " ----- matrix IA = \n " << ia << endl;
    30 // Extraction de sous tableau
     33  // sub array extraction, Range(2,3) : starting position=2 , size=3
    3134  TArray<int_4> ic = ia(Range(2,3),Range(1,2));
    3235  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
    3338  ic = 0;
    3439  cout << " ----- matrix IC Apres (=0) = \n " << ic << endl;
     
    3742  cout << "  :::: 3 Dim arrays ::::: " << endl;
    3843  TArray<int_4>::SetMaxPrint(1000);
     44  // Creating 3-dim array (X=8 x Y=7 x Z=2) , filling it with 5
    3945  TArray<int_4> ib(8,7,2);
    4046  ib = 5;
    4147  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
    4250  ib(Range(1,4),Range(2,3)) *= 3;
    4351  cout << " -- matrix IB , Apres ib(Range(1,3),Range(2,1))*=3 : " << endl;
    4452  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;
    4565  }
    4666  catch (PThrowable exc) {
  • trunk/SophyaProg/Tests/lpk.cc

    r786 r789  
    2929    for(j=0; j<n; j++)  a(i,j,0) = GauRnd(0., 1.);
    3030 
    31   TArray<r_4> x(1,n), b(n,n);
     31  TArray<r_4> x(n,1), b(n,1);
    3232  r_4 sum ;
    33   for(i=0; i<n; i++) x(0,i,0) = GauRnd(2., 1.5);
     33  for(i=0; i<n; i++) x(i,0,0) = GauRnd(2., 1.5);
    3434  for(i=0; i<n; i++) {
    3535    sum = 0.;
    36     for(j=0; j<n; j++) sum +=  a(j,i,0)*x(0,j,0);
    37     b(0,i,0) = sum;
     36    for(j=0; j<n; j++) sum +=  a(i,j,0)*x(j,0,0);
     37    b(i,0,0) = sum;
    3838  }
    3939
Note: See TracChangeset for help on using the changeset viewer.