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