本文整理汇总了C++中eigen::Matrix::jacobiSvd方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::jacobiSvd方法的具体用法?C++ Matrix::jacobiSvd怎么用?C++ Matrix::jacobiSvd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix
的用法示例。
在下文中一共展示了Matrix::jacobiSvd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lstsq
void lstsq(const Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic> &A,
const Eigen::Matrix<ScalarT, Eigen::Dynamic, 1> &b,
Eigen::Matrix<ScalarT, Eigen::Dynamic, 1> &x)
{
if (A.rows() == A.cols()) {
// solve via pivoting
x = A.colPivHouseholderQr().solve(b);
} else if (A.rows() > A.cols()) {
// solving via SVD
x = A.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(b);
} else {
x.fill(std::numeric_limits<ScalarT>::quiet_NaN());
std::cout << "Error solving linear system" << std::endl;
return;
}
}
示例2: matAInhomogeneous
const CPoint3DCAMERA CMiniVisionToolbox::getPointStereoLinearTriangulationSVDLS( const cv::Point2d& p_ptPointLEFT, const cv::Point2d& p_ptPointRIGHT, const Eigen::Matrix< double, 3, 4 >& p_matProjectionLEFT, const Eigen::Matrix< double, 3, 4 >& p_matProjectionRIGHT )
{
//ds A matrix for system: A*X=0
Eigen::Matrix< double, 4 , 4 > matAHomogeneous;
//ds fill the matrix
matAHomogeneous.row(0) = p_ptPointLEFT.x*p_matProjectionLEFT.row(2)-p_matProjectionLEFT.row(0);
matAHomogeneous.row(1) = p_ptPointLEFT.y*p_matProjectionLEFT.row(2)-p_matProjectionLEFT.row(1);
matAHomogeneous.row(2) = p_ptPointRIGHT.x*p_matProjectionRIGHT.row(2)-p_matProjectionRIGHT.row(0);
matAHomogeneous.row(3) = p_ptPointRIGHT.y*p_matProjectionRIGHT.row(2)-p_matProjectionRIGHT.row(1);
//ds inhomogeneous solution
const Eigen::Matrix< double, 4, 3 > matAInhomogeneous( matAHomogeneous.block< 4, 3 >( 0, 0 ) );
const Eigen::Vector4d vecRHS( -matAHomogeneous.col( 3 ) );
//ds solve the system and return
return matAInhomogeneous.jacobiSvd( Eigen::ComputeFullU | Eigen::ComputeFullV ).solve( vecRHS );
}