- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all!
Eigenvalues that I obtained all come right, but eigenvectors turned out to be just zeros. Could you please help me to solve this problem (to determine eigenvectors).
int n = 3;
myComplex *A = new myComplex[n*n];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
A[i+j*n] = zeroC;
real(A[0]) = 1.; real(A[1]) = 6.; real(A[2]) = -1.;
real(A[3]) = 2.; real(A[4]) = -1; real(A[5]) = -2.;
real(A[6]) = 1.; real(A[7]) = 0.; real(A[8]) = -1.;
myComplex *w = new myComplex
for(int i = 0; i < n; i++)
w = zeroC;
myComplex *vr = new myComplex[n*n];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
vr[i+j*n] = zeroC;
int ilo = 1;
int ihi = n;
int lda = std::max(1,n);
myComplex* tau = new myComplex[std::max(1,n-1)];
myComplex* work = new myComplex[std::max(1,n*n)];
int lwork = std::max(1,n);
int info;
ZGEHRD(
&n,
&ilo,
&ihi,
(MKL_Complex16*)A,
&lda,
(MKL_Complex16*)(&tau[0]),
(MKL_Complex16*)(&work[0]),
&lwork,
&info
);
myComplex *ACopy = new myComplex[n*n];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
ACopy[i+j*n] = A[i+j*n];
const char job = 'S';
const char compz = 'V';
int ldh = std::max(1,n);
int ldz = std::max(1,n);
ZHSEQR(
&job,
&compz,
&n,
&ilo,
&ihi,
(MKL_Complex16*)A,
&ldh,
(MKL_Complex16*)(&w[0]),
(MKL_Complex16*)ACopy,
&ldz,
(MKL_Complex16*)(&work[0]),
&lwork,
&info
);
const char side = 'R';
const char howmny = 'S';
int* select = new int[std::max(1,n)];
int ldt = std::max(1,n);
int ldvl = 1;
int ldvr = n;
int m = n;
int mm = m;
double* rwork = new double[std::max(1,n)];
ZTREVC(
&side,
&howmny,
select,
&n,
(MKL_Complex16*)A,
&ldt,
(MKL_Complex16*)&zeroC,
&ldvl,
(MKL_Complex16*)(&vr[0]),
&ldvr,
&mm,
&m,
(MKL_Complex16*)(&work[0]),
&rwork[0],
&info
);
std::cout << "\nEigenvalues: ";
for(int i = 0; i < n; i++)
std::cout << "\n" << w;
std::cout << "\nEigenvectors: ";
for(int j = 0; j < n; j++)
for(int i = 0; i < n; i++)
std::cout << "\n" << vr[i+j*n];
delete[] A; delete[] w; delete[] vr;
delete[] ACopy;
delete[] tau;
delete[] work;
delete[] select;
Thanks a lot in advance!
Link Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page