得到eigen :: selfadjointView <lower>()</lower>的上三角形

时间:2013-01-25 16:37:31

标签: c++ eigen

我有这个工作正常:

MatrixXf Sig(p,p);
Sig.selfadjointView<Lower>().rankUpdate(xSub.adjoint());

现在,我还需要获得上三角形 Sig的一部分。 This答案似乎表明了这一点 做

Sig.triangularView<StrictUpper>()=Sig.adjoint().triangularView<StrictUpper>(); 

但这样做会导致混乱 - 或者正如编译器所说的那样:

DetMCD_1.cpp: In function ‘float CStep(const MatrixXf&, Eigen::VectorXi&, const int&, const int&)’:
DetMCD_1.cpp:263:21: error: ‘StrictUpper’ was not declared in this scope
DetMCD_1.cpp:263:34: error: no matching function for call to ‘Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001>::triangularView()’
DetMCD_1.cpp:263:34: note: candidates are:
/home/kaveh/R/x86_64-pc-linux-gnu-library/2.15/RcppEigen/include/Eigen/src/Core/MatrixBase.h:248:79: note: template<unsigned int Mode> typename Eigen::MatrixBase<Derived>::TriangularViewReturnType<Mode>::Type Eigen::MatrixBase::triangularView() [with unsigned int Mode = Mode, Derived = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001>, typename Eigen::MatrixBase<Derived>::TriangularViewReturnType<Mode>::Type = <type error>]
/home/kaveh/R/x86_64-pc-linux-gnu-library/2.15/RcppEigen/include/Eigen/src/Core/MatrixBase.h:249:84: note: template<unsigned int Mode> typename Eigen::MatrixBase<Derived>::ConstTriangularViewReturnType<Mode>::Type Eigen::MatrixBase::triangularView() const [with unsigned int Mode = Mode, Derived = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001>, typename Eigen::MatrixBase<Derived>::ConstTriangularViewReturnType<Mode>::Type = <type error>]
DetMCD_1.cpp:263:78: error: no matching function for call to ‘Eigen::Transpose<const Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001> >::triangularView() const’
DetMCD_1.cpp:263:78: note: candidates are:
/home/kaveh/R/x86_64-pc-linux-gnu-library/2.15/RcppEigen/include/Eigen/src/Core/MatrixBase.h:248:79: note: template<unsigned int Mode> typename Eigen::MatrixBase<Derived>::TriangularViewReturnType<Mode>::Type Eigen::MatrixBase::triangularView() [with unsigned int Mode = Mode, Derived = Eigen::Transpose<const Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001> >, typename Eigen::MatrixBase<Derived>::TriangularViewReturnType<Mode>::Type = <type error>]
/home/kaveh/R/x86_64-pc-linux-gnu-library/2.15/RcppEigen/include/Eigen/src/Core/MatrixBase.h:249:84: note: template<unsigned int Mode> typename Eigen::MatrixBase<Derived>::ConstTriangularViewReturnType<Mode>::Type Eigen::MatrixBase::triangularView() const [with unsigned int Mode = Mode, Derived = Eigen::Transpose<const Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001> >, typename Eigen::MatrixBase<Derived>::ConstTriangularViewReturnType<Mode>::Type = <type error>]
make: *** [DetMCD_1.o] Error 1

我的问题是:鉴于我有 Sig的下三角部分,如何 说服艾根让我满满的 基质

1 个答案:

答案 0 :(得分:2)

这是因为有拼写错误,它是StrictlyUpper,而不是StrictUpper。请参阅相应的doc。以下两行是等效的:

长版:

M.triangularView<StrictlyUpper>()=M.adjoint().triangularView<StrictlyUpper>();

简短版本:

M.triangularView<StrictlyUpper>()=M.adjoint();

请注意,在大多数情况下,您不需要明确计算上三角形部分。