0

Rで次のことを実行します。

> m = matrix(c(0.563291, -0.478813,  0.574175,
+ 0.160779,  -0.03407,  0.381922,
+ 0.0677914,  0.870361,  -0.88602), 3, 3)
> mt = t(m)
> mt

[1,] 0.5632910 -0.478813  0.574175
[2,] 0.1607790 -0.034070  0.381922
[3,] 0.0677914  0.870361 -0.886020
> e<-eigen(mt)
> e
$values
[1] -1.1583554  0.5215205  0.2800359

$vectors

[1,] -0.3684057 0.8245987 -0.1255897
[2,] -0.2513624 0.4625355 -0.7915182
[3,]  0.8950387 0.3257267 -0.5981021

次の C++ コードを使用した eigen3:

std::cout << "=========" << std::endl;
std::cout << A << std::endl;

EigenSolver<MatrixXd> es(A);

std::cout << "evals: " << std::endl;
std::cout << es.eigenvalues();
std::cout << std::endl << "evecs: " << std::endl;
std::cout << es.eigenvectors() << std::endl;
std::cout << "=========" << std::endl;

次の値を取得します。

=========
0.563291 -0.478813  0.574175
0.160779  -0.03407  0.381922
0.0677914  0.870361  -0.88602

evals: 
(0.521521,0)
(0.280036,0)
(-1.15836,0)
evecs: 
(-0.824599,0)  (0.125591,0) (-0.368406,0)
(-0.462535,0)  (0.791518,0) (-0.251362,0)
(-0.325726,0)  (0.598102,0)  (0.895039,0)
=========

eigen3 と R で順序が異なるのはなぜですか? 「最高の固有値と対応する固有ベクトル」形式で情報を保存および出力するための固有バージョンを探しています。行ベクトルの代わりに、-1 を掛けて値をオフにしますか?

R の evs 出力と Eigen の evs 出力を取り、それらが等しい場合は互いに乗算すると、恒等行列 I を取得する必要があります。

> v = matrix(c(-0.3684057, 0.8245987, -0.1255897,
+       -0.2513624, 0.4625355, -0.7915182,
+       0.8950387, 0.3257267, -0.5981021), nrow = 3, ncol = 3)
> v
           [,1]       [,2]       [,3]
[1,] -0.3684057 -0.2513624  0.8950387
[2,]  0.8245987  0.4625355  0.3257267
[3,] -0.1255897 -0.7915182 -0.5981021

> u = matrix(c(-0.824599, 0.125591, -0.368406,
+            -0.462535, 0.791518, -0.251362,
+            -0.325726,  0.598102, 0.895039), nrow = 3, ncol = 3)
> u
          [,1]      [,2]      [,3]
[1,] -0.824599 -0.462535 -0.325726
[2,]  0.125591  0.791518  0.598102
[3,] -0.368406 -0.251362  0.895039

> c = u*v
> c
          [,1]      [,2]       [,3]
[1,] 0.3037870 0.1162639 -0.2915374
[2,] 0.1035622 0.3661052  0.1948178
[3,] 0.0462680 0.1989576 -0.5353247

> u = t(u)
> u
          [,1]     [,2]      [,3]
[1,] -0.824599 0.125591 -0.368406
[2,] -0.462535 0.791518 -0.251362
[3,] -0.325726 0.598102  0.895039
> c = u*v
> c
            [,1]        [,2]        [,3]
[1,]  0.30378697 -0.03156886 -0.32973763
[2,] -0.38140576  0.36610517 -0.08187531
[3,]  0.04090783 -0.47340862 -0.53532471
> 
4

1 に答える 1

1

それらを並べ替えることができます。

Rの場合、ドキュメントには

Value:

     The spectral decomposition of ‘x’ is returned as components of a
     list with components

  values: a vector containing the p eigenvalues of ‘x’, sorted in
          _decreasing_ order, according to ‘Mod(values)’ in the
          asymmetric case when they might be complex (even for real
          matrices).  For real asymmetric matrices the vector will be
          complex only if complex conjugate pairs of eigenvalues are
          detected.

値を並べ替える必要はありません。そうするのは単なる規則です。

(また、関連するベクトルの符号に関する質問も準 FAQ です。)

于 2014-12-31T19:16:31.470 に答える