Menu

[r24]: / trunk / test / dsymatrix / dsymatrix-lapack / dsyev_check.cpp  Maximize  Restore  History

Download this file

103 lines (82 with data), 2.5 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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
//=============================================================================
void dsyev_check_value()
{
cout << "############ check dsyev value ############" << endl;
srand(time(NULL));
int N(3);
//// make dsymatrix A ////
CPPL::dsymatrix A(N);
for(int i=0; i<N; i++){ for(int j=0; j<N; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
}}
//// make wr wi vr ////
vector<double> w;
//// make A_original ////
CPPL::dsymatrix A_original(A);
//// dsyev ////
A.dsyev(w);
//A.dsyev(w,1);
//// print ////
cout << "A=\n" << A << endl;
cout << "A_original=\n" << A_original << endl;
for(int i=0; i<N; i++){
cout << "#### " << i << "th eigen ####" << endl;
cout << "w=" << w[i] <<endl;
}
}
//=============================================================================
void dsyev_check_right()
{
cout << "############ check dsyev right ############" << endl;
srand(time(NULL));
int N(3);
//// make dsymatrix A ////
CPPL::dsymatrix A(N);
for(int i=0; i<A.n; i++){ for(int j=0; j<A.n; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
}}
//// make wr wi vr ////
vector<double> w;
vector<CPPL::dcovector> v;
//// make A_original ////
CPPL::dsymatrix A_original(A);
//// dsyev ////
A.dsyev(w,v);
//// print ////
cout << "A_original=\n" << A_original << endl;
for(int i=0; i<A.n; i++){
cout << "#### " << i << "th eigen ####" << endl;
cout << "w=" << w[i] <<endl;
cout << "v=\n" << v[i] <<endl;
cout << "[A]*{x} -lambda*{x} = (Should be zeros)\n"
<< A_original*v[i] -w[i]*v[i] << endl;
}
}
//=============================================================================
void dsyev_check_left()
{
cout << "############ check dsyev left ############" << endl;
srand(time(NULL));
int N(3);
//// make dsymatrix A ////
CPPL::dsymatrix A(N);
for(int i=0; i<A.n; i++){ for(int j=0; j<A.n; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
}}
//// make wr wi vl ////
vector<double> w;
vector<CPPL::drovector> v;
//// make A_original ////
CPPL::dsymatrix A_original(A);
//// dsyev ////
A.dsyev(w, v);
//// print ////
cout << "A_original=\n" << A_original << endl;
for(int i=0; i<A.n; i++){
cout << "#### " << i << "th eigen ####" << endl;
cout << "w = " << w[i] << endl;
cout << "v = " << v[i] << endl;
cout << "{x}*[A] -{x}*lambda = (Should be zeros)\n"
<< v[i]*A_original -v[i]*w[i] << 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.