【发布时间】:2017-06-21 11:44:22
【问题描述】:
matlab有一个功能:
Z = null(A);
这个 MATLAB 函数是获得的 A 的零空间的正交基 从奇异值分解。
我必须在 eigen 库上将 MATLAB 代码转换为 C++,但我不知道该怎么做。 我试过了:
MatrixXf m = MatrixXf::Random(3,5);
cout << "Here is the matrix m:" << endl << m << endl;
MatrixXf ker = m.fullPivLu().kernel();
cout << "Here is a matrix whose columns form a basis of the kernel of m:"
<< endl << ker << endl;
输出:
Here is the matrix m:
0.68 0.597 -0.33 0.108 -0.27
-0.211 0.823 0.536 -0.0452 0.0268
0.566 -0.605 -0.444 0.258 0.904
Here is a matrix whose columns form a basis of the kernel of m:
-0.219 0.763
0.00335 -0.447
0 1
1 0
-0.145 -0.285
这不是零空间的“正交”基。
【问题讨论】:
-
单独的LU分解只能提取零空间的任意基。要获得正交标准,您需要一些 QR 分解或 SVD。
-
@ggael 但我不知道如何使用 QR 分解或 SVD 来计算零空间的正交基......
标签: c++ matrix linear-algebra eigen eigen3