正方行列 が与えられた場合、の 5 つの最大固有値を含む対角行列と、列が対応する固有ベクトルである行列A
を取得する必要があります。Matlab では、コードは. ArrayFire C++ に同様の関数はありますか?D
A
V
[V,D] = eigs(A,5)
ArrayFire ではaf::eigen(Values,Vectors,A)
. の要素の順序は何Values
ですか? あるテストでは、要素をValues
大きさの大きい順に並べ替えましたが、他のケースでValues
は、大きさの小さい順に並べ替えました。基本的に、最大の大きさの固有値に対応する 5 つの固有ベクトルを抽出する必要があります。sort
これを達成するために関数を使用する必要がありますか?
更新 簡単な例を次に示します。
// first example
float a[]={1, 2, 5, -2, 1, -5, 3, -2, 1};
array b(3,3,a);
array evalues, evectors;
af::eigen(evalues, evectors, b);
print(evalues); //`evalues` are not in order
// second example
float a2[]={1, -3, 3, 3, -5, 3, 6, -6, 4};
array b2(3,3,a2);
array evalues2, evectors2;
af::eigen(evalues2, evectors2, b2);
print(evalues2); //`evalues2` are in the decreasing order