source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Tests/tsttvec.cc@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 2.4 KB
Line 
1#include "machdefs.h"
2#include <iostream.h>
3#include <stdlib.h>
4#include <stdio.h>
5#include <string.h>
6#include <math.h>
7#include "outilsinit.h"
8#include "pexceptions.h"
9#include "cvector.h"
10#include "tvector.h"
11#include "nbrandom.h"
12
13////////////////////////////////////////////////////////////////////////////////////////
14int main(int narg,char *arg[])
15{
16PeidaInit();
17r_8 v[10] = {1,2,3,4,5,6,7,8,9,10};
18{
19cout<<"TVector(10)"<<endl;
20TVector<r_8> v1(10);
21{for(int i=0;i<10;i++) v1(i)=100+i;}
22cout<<"nel="<<v1.NElts()<<endl<<v1;
23
24{
25cout << " Test ecriture PPersist TVector " << endl;
26FIO_TVector<r_8> ftv(v1);
27ftv.Write("tvec.ppf");
28}
29{
30cout << " Test lecture PPersist TVector " << endl;
31FIO_TVector<r_8> ftv("tvec.ppf");
32cout<<"Vlue:"<<(TVector<r_8>)ftv<<endl;
33}
34
35
36cout<<"TVector(10,v,br)"<<endl;
37TVector<r_8> v2(10,v,new Bridge); cout<<v2;
38
39cout<<"TVector()"<<endl;
40TVector<r_8> v3; cout<<v3;
41
42cout<<"v3 = v1"<<endl;
43v3 = v1; cout<<v3;
44
45cout<<"v3 = 123456"<<endl;
46v3 = 123456.; cout<<v3;
47
48cout<<"ps = v1 * v2"<<endl;
49r_8 ps = v1 * v2; cout<<"ps="<<ps<<endl;
50
51cout<<"v2 = 10.*v1"<<endl;
52v2 = 10.*v1; cout<<v2;
53cout<<"v2 = v2*0.1"<<endl;
54v2 = v2*0.1; cout<<v2;
55
56cout<<"v2 = v1/10."<<endl;
57v2 = v1/10.; cout<<v2;
58cout<<"v2 = v2/0.1"<<endl;
59v2 = v2/0.1; cout<<v2;
60
61cout<<"v2 = 10.+v1"<<endl;
62v2 = 10.+v1; cout<<v2;
63cout<<"v2 = v2-10."<<endl;
64v2 = v2-10.; cout<<v2;
65
66cout<<"v2 = 10.-v1"<<endl;
67v2 = 10.-v1; cout<<v2;
68cout<<"v2 = (-1.)*v2+10."<<endl;
69v2 = (-1.)*v2+10.; cout<<v2;
70
71cout<<"v2 += 10."<<endl;
72v2 += 10.; cout<<v2;
73cout<<"v2 -= 10."<<endl;
74v2 -= 10.; cout<<v2;
75cout<<"v2 *= 10."<<endl;
76v2 *= 10.; cout<<v2;
77cout<<"v2 /= 10."<<endl;
78v2 /= 10.; cout<<v2;
79
80cout<<"v3.ReSize(4)"<<endl;
81v3.ReSize(4);
82{for(int i=0;i<4;i++) v3(i)=i+1;} cout<<v3;
83TMatrix<r_8> M(2,4);
84{for(int i=0;i<8;i++) M[i]=i+1;} cout<<M;
85TVector<r_8> v4(10);
86v4 = M*v3; cout<<v4;
87
88cout<<"LinSolve(A,B,X)"<<endl;
89TMatrix<r_8> A(5,5);
90TVector<r_8> B(5);
91{for(int i=0;i<25;i++) {A[i]=drand01(); if(i<5) B(i)=drand01();}}
92TVector<r_8> X;
93X = B;
94cout<<"A = "<<A; cout<<"B = "<<B;
95r_8 d=0.;
96d = LinSolve(A,B,X);
97cout<<"d="<<d<<endl; cout<<"X = "<<X;
98X = A*X; cout<<"A*X = "<<X;
99X -= B; cout<<"B-X = "<<X;
100cout<<"LinSolveInPlace(A,B)"<<endl;
101X = B;
102d = LinSolveInPlace(A,X);
103cout<<"d="<<d<<endl; cout<<"X = "<<X;
104
105cout<<"Conversion en ancien Vector"<<endl;
106Vector Vold(v1);
107cout<<"Vold = "<<Vold;
108
109} // destruction de toutes les vecteurs
110exit(0);
111}
Note: See TracBrowser for help on using the repository browser.