Menu

[r47]: / trunk / test / zhematrix / zhematrix-lapack / zhesv_check.cpp  Maximize  Restore  History

Download this file

78 lines (63 with data), 2.1 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
72
73
74
75
76
77
//=============================================================================
/*! zhesv_check */
void zhesv_check_vector()
{
cout << "############ check zhesv vector ############" << endl;
srand(time(NULL));
int N(3);
//// make zhematrix A ////
CPPL::zhematrix A(N);
for(int i=0; i<A.n; i++){
for(int j=0; j<i; j++){
A(i,j) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}
A(i,i) =complex<double>(rand()/(RAND_MAX/10), 0.0);
}
//// make zcovector y ////
CPPL::zcovector y(N);
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::zhematrix 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.zhesv(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 zhesv_check_matrix()
{
cout << "############ check zhesv matrix ############" << endl;
srand(time(NULL));
int N(3);
//// make zhematrix A ////
CPPL::zhematrix A(N);
for(int i=0; i<A.n; i++){
for(int j=0; j<i; j++){
A(i,j) =complex<double>(rand()/(RAND_MAX/10), rand()/(RAND_MAX/10));
}
A(i,i) =complex<double>(rand()/(RAND_MAX/10), 0.0);
}
//// make zhematrix Y ////
CPPL::zgematrix Y(N,N);
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::zhematrix 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.zhesv(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.