LAPACKE を使用して一般化された固有値問題 A*V = lambda*B*V を解決していますが、固有値と右固有ベクトルの両方が必要です。しかし問題は、正しい固有値しか得られず、固有ベクトルが間違っていることです。実際に、コードを使用して、このリンクhttp://www.nag.com/numeric/FL/nagdoc_fl22/examples/baseresults/f08ykfe.rの例をテストしました。成功です。では、なぜこのケースではうまくいかないのか疑問に思っています。コードと結果を以下に掲載します。誰かヒントを教えてくれませんか?どうもありがとう。
double AAtest[4] = {-1.999783, 0, 0, 1.999783};
double BBtest[4] = {2.167327e-4, 1.999783, 1.999783, 0};
int i, j, N = 2;
int matrix_order = LAPACK_COL_MAJOR;
double *RR, *QQ, *ZZ, *alphar, *alphai, *beta;
int *select, m;
int info1, info2, info3, info4, info5, info6, info7;
int ilo, ihi;
double *lscale, *rscale, *tau;
RR = (double *)calloc(N*N, sizeof(double));
QQ = (double *)calloc(N*N, sizeof(double));
ZZ = (double *)calloc(N*N, sizeof(double));
alphar = (double *)calloc(N, sizeof(double));
alphai = (double *)calloc(N, sizeof(double));
beta = (double *)calloc(N, sizeof(double));
select = (int *)calloc(N, sizeof(int));
lscale = (double *)calloc(N, sizeof(double));
rscale = (double *)calloc(N, sizeof(double));
tau = (double *)calloc(N, sizeof(double));
for (i = 0; i < N; i++)
select[i] = 1;
info1 = LAPACKE_dggbal(matrix_order, 'B', N, AA, N, BB, N, &ilo, &ihi, lscale, rscale);
info2 = LAPACKE_dgeqrf(matrix_order, N, N, BB, N, tau);
for (i = 0; i < N; i++){
for (j = i; j < N; j++){
RR[j*N+i] = BB[j*N+i];
BB[j*N+i] = 0;
}
}
info3 = LAPACKE_dormqr(matrix_order, 'L', 'T', N, N, N, BB, N, tau, AA, N);
info4 = LAPACKE_dgghrd(matrix_order, 'I', 'I', N, ilo, ihi, AA, N, RR, N, QQ, N, ZZ, N);
info5 = LAPACKE_dhgeqz(matrix_order, 'S', 'V', 'V', N, ilo, ihi, AA, N, RR, N, alphar, alphai, beta, QQ, N, ZZ, N);
info6 = LAPACKE_dtgevc(matrix_order, 'R', 'B', select, N, AA, N, RR, N, QQ, N, ZZ, N, N, &m);
info7 = LAPACKE_dggbak(matrix_order, 'B', 'R', N, ilo, ihi, lscale, rscale, m, ZZ, N);
結果:
Input matrix AA....................................
-1.999783e+00 0.000000e+00
0.000000e+00 1.999783e+00
Input matrix BB....................................
2.167327e-04 1.999783e+00
1.999783e+00 0.000000e+00
After balancing AA...................
-1.999783e+02 0.000000e+00
0.000000e+00 1.999783e+00
After balancing BB...................
2.167327e-02 1.999783e+01
1.999783e+01 0.000000e+00
R factor.............................
-1.999784e+01 -2.167326e-02
0.000000e+00 -1.999782e+01
Q'*A.................................
2.167326e-01 -1.999782e+00
1.999782e+02 2.167326e-03
Hessenberg form of AA................
2.167326e-01 -1.999782e+00
1.999782e+02 2.167326e-03
triangular form of BB................
-1.999784e+01 -2.167326e-02
0.000000e+00 -1.999782e+01
Eigenvalues..........................
-0.000054 + j1.000000
-0.000054 + j-1.000000
Schur form of AA................
-9.904398e+01 1.009890e+02
-1.009890e+02 9.893453e+01
Schur form of BB................
2.000867e+01 0.000000e+00
0.000000e+00 1.998700e+01
Right eigenvectors.....................
-9.090507e-02 9.090506e-01
-9.090457e-01 -9.095433e-02
しかし、この問題を解決するために matlab を使用すると、取得した固有ベクトルは次のようになります。
-0.500000000733645 - 0.499999999266355i -0.500000000733645 + 0.499999999266355i
0.500027093059538 - 0.499972905472315i 0.500027093059538 + 0.499972905472315i
助けてください...ありがとう!