0

我有这个工作正常:

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

现在,我还需要获取Sig. 这个答案似乎建议做

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,如何说服 eigen 将完整矩阵归还给我?

4

1 回答 1

2

这是因为有错字,它是 StrictlyUpper,而不是 StrictUpper。请参阅相应的文档。以下两行是等价的:

长版:

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

精简版:

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

请,也不是在大多数情况下您不需要显式计算上三角部分。

于 2013-01-25T18:28:13.083 回答