Changeset 1348 in Sophya for trunk/SophyaProg/Tests/tstndblk.cc
- Timestamp:
- Nov 26, 2000, 12:02:05 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/tstndblk.cc
r945 r1348 10 10 #include "pexceptions.h" 11 11 #include "ndatablock.h" 12 13 void Fonction(NDataBlock<r_4> Arg); 14 NDataBlock<r_4> Fonction2(NDataBlock<r_4> Arg); 15 16 void Fonction(NDataBlock<r_4> Arg) 17 { 18 cout<<"Fonction: arg.Size()="<<Arg.Size()<<" arg.Data()="<<Arg.Data()<<endl; 19 } 20 NDataBlock<r_4> Fonction2(NDataBlock<r_4> Arg) 21 { 22 cout<<"Fonction2: arg.Size()="<<Arg.Size()<<" arg.Data()="<<Arg.Data()<<endl; 23 return Arg; 24 } 12 25 13 26 ////////////////////////////////////////////////////////////////////////////// … … 31 44 SophyaInit(); 32 45 const int NDim = 8; 33 float *x1 = new float[NDim];34 float *x2 = new float[NDim];35 float *x3 = new float[NDim];46 r_4 *x1 = new r_4[NDim]; 47 r_4 *x2 = new r_4[NDim]; 48 r_4 *x3 = new r_4[NDim]; 36 49 for(int k=0;k<NDim;k++) 37 50 {x1[k]=k+1; x2[k]=(k+1)*10; x3[k]=(k+1)*100;} … … 57 70 //----------------------------------------------------- 58 71 cout<<endl<<"Createur A1(3)"<<endl; 59 NDataBlock< float> A1(3);72 NDataBlock<r_4> A1(3); 60 73 cout<<endl<<"Createur B1("<<NDim<<")"<<endl; 61 NDataBlock< float> B1(NDim);74 NDataBlock<r_4> B1(NDim); 62 75 A1.FillFrom(NDim,x1); A1.Print(0,999); 63 76 B1.FillFrom(NDim,x1); B1.Print(0,999); 64 77 65 78 cout<<endl<<"Createur A2(3)"<<endl; 66 NDataBlock< float> A2(3);79 NDataBlock<r_4> A2(3); 67 80 A2.FillFrom(NDim,x2); A2.Print(0,999); 68 81 cout<<endl<<"Createur B2("<<NDim<<")"<<endl; 69 NDataBlock< float> B2(NDim);82 NDataBlock<r_4> B2(NDim); 70 83 B2.FillFrom(NDim,x2); B2.Print(0,999); 71 84 72 85 cout<<endl<<"Createur A3(3)"<<endl; 73 NDataBlock< float> A3(3);86 NDataBlock<r_4> A3(3); 74 87 A3.FillFrom(NDim,x3); A3.Print(0,999); 75 88 cout<<endl<<"Createur B3("<<NDim<<")"<<endl; 76 NDataBlock< float> B3(NDim);89 NDataBlock<r_4> B3(NDim); 77 90 B3.FillFrom(NDim,x3); B3.Print(0,999); 78 91 79 92 //----------------------------------------------------- 80 93 cout<<endl<<"Createur par copie AA1(A1)"<<endl; 81 NDataBlock< float> AA1(A1);94 NDataBlock<r_4> AA1(A1); 82 95 83 96 cout<<endl<<"Createur par copie BB1(B1)"<<endl; 84 NDataBlock< float> BB1(B1);97 NDataBlock<r_4> BB1(B1); 85 98 86 99 {cout<<endl<<"Createur par copie {BBB1(B1)}"<<endl; 87 NDataBlock< float> BBB1(B1);}100 NDataBlock<r_4> BBB1(B1);} 88 101 89 102 {cout<<endl<<"Createur avec bridge {Abr("<<NDim<<",x3,new Bridge)}"<<endl; 90 NDataBlock< float> Abr(NDim,x3,new Bridge);103 NDataBlock<r_4> Abr(NDim,x3,new Bridge); 91 104 Abr.Print(0,999); 92 105 cout<<"x3 existe encore: "<<x3[0]<<",...,"<<x3[4]<<endl;} 93 106 94 107 {cout<<endl<<"Createur avec bridge {Abr("<<NDim<<",dum,NULL)}"<<endl; 95 float *dum = new float[10];108 r_4 *dum = new r_4[10]; 96 109 for(int i=0;i<10;i++) dum[i] = 1000.+i; 97 NDataBlock< float> Abr(10,dum);110 NDataBlock<r_4> Abr(10,dum); 98 111 Abr.Print(0,999);} 99 112 100 113 //----------------------------------------------------- 101 cout<<endl<<endl; 102 NDataBlock<float> AC(3); 114 cout<<endl<<"Passage par argument a une fonction"<<endl; 115 NDataBlock<r_4> Arg; 116 cout<<"... Argument cree par defaut"<<endl; 117 Fonction(Arg); 118 cout<<"... Argument normal"<<endl; 119 Fonction(A1); 120 121 cout<<endl<<"Passage par argument a une fonction avec retour d un NDataBlock"<<endl; 122 cout<<"... Argument cree par defaut"<<endl; 123 NDataBlock<r_4> fdum = Fonction2(Arg); cout<<fdum; 124 NDataBlock<r_4> fdum1(Fonction2(Arg)); cout<<fdum1; 125 cout<<"... Argument normal"<<endl; 126 NDataBlock<r_4> fdum2 = Fonction2(A1); cout<<fdum2; 127 NDataBlock<r_4> fdum3(Fonction2(A1)); cout<<fdum3; 128 129 //----------------------------------------------------- 130 cout<<endl<<endl; 131 NDataBlock<r_4> AC(3); 103 132 AC.Reset(); 104 133 cout<<endl<<"AC=2"<<endl;
Note:
See TracChangeset
for help on using the changeset viewer.