Menu

[r31]: / trunk / test / zgematrix / zgematrix-lapack / zgesv_check.cpp  Maximize  Restore  History

Download this file

72 lines (57 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//=============================================================================
/*! zgesv_check */
void zgesv_check_vector()
{
cout << "############ check zgesv vector ############" << endl;
srand(time(NULL));
int M(3);
//// make zgematrix A ////
CPPL::zgematrix A(M,M);
for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
A(i,j) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}}
//// make zcovector y ////
CPPL::zcovector y(M);
for(int i=0; i<y.l; i++){
y(i) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}
//// make A_original and y_original ////
CPPL::zgematrix A_original(A);
CPPL::zcovector y_original(y);
cout << "A_original=\n" << A_original << endl;
cout << "y_original=\n" << y_original << endl;
//// solve Ax=y ////
A.zgesv(y);
//// print A, y and A_original*y ////
cout << "A=\n" << A << endl;
cout << "y=\n" << y << endl;
cout << "A_original*y=\n" << A_original*y << endl;
}
//=============================================================================
void zgesv_check_matrix()
{
cout << "############ check zgesv matrix ############" << endl;
srand(time(NULL));
int M(3);
//// make zgematrix A ////
CPPL::zgematrix A(M,M);
for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
A(i,j) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}}
//// make zgematrix Y ////
CPPL::zgematrix Y(M,M);
for(int i=0; i<Y.m; i++){ for(int j=0; j<Y.n; j++){
Y(i,j) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}}
//// make A_original and Y_original ////
CPPL::zgematrix A_original(A);
CPPL::zgematrix Y_original(Y);
cout << "A_original=\n" << A_original << endl;
cout << "Y_original=\n" << Y_original << endl;
//// solve AY=B ////
A.zgesv(Y);
//// print A, Y and A_original*Y ////
cout << "A=\n" << A << endl;
cout << "Y=\n" << Y << endl;
cout << "A_original*Y=\n" << A_original*Y << endl;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.