"我们使用快速的 SVD 分解,仅计算 A 矩阵 SVD 结果的最后一列。"....
This is used in both line and plane fitting. For example, the code is here
Eigen::JacobiSVD svd(A, Eigen::ComputeThinV);
plane_coeffs = svd.matrixV().col(3);
On my machine, it turns out that Eigen::SelfAdjointEigenSolver is 2x faster, possibly because it only operates on an nxn symmetric matrices, whereas SVD works on mxn general matrices:
Eigen::MatrixXf ATA = A.transpose() * A; // Compute A^T A
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXf> solver(ATA); // Efficient for symmetric matrices
if (solver.info() != Eigen::Success) {
throw std::runtime_error("Eigen decomposition failed!");
}
return {solver.eigenvalues(), solver.eigenvectors()};
I understand that it's the method that the book uses, so I'm happy to leave this as a comment instead of a PR. Well, please feel free to close if this makes sense 😊 @gaoxiang12
This is used in both line and plane fitting. For example, the code is here
On my machine, it turns out that
Eigen::SelfAdjointEigenSolveris 2x faster, possibly because it only operates on an nxn symmetric matrices, whereas SVD works on mxn general matrices:I understand that it's the method that the book uses, so I'm happy to leave this as a comment instead of a PR. Well, please feel free to close if this makes sense 😊 @gaoxiang12