This forum has been archived. All content is frozen. Please use KDE Discuss instead.

passing MatrixXd as a function parameter and triangularView

Tags: None
(comma "," separated)
bkot
Registered Member
Posts
11
Karma
0
I followed this tutorial: http://eigen.tuxfamily.org/dox/TopicFun ... Types.html
and created the following function
Code: Select all
void f(Eigen::MatrixBase<Derived> const &r_) {
    Eigen::MatrixBase<Derived>& r = const_cast<Eigen::MatrixBase<Derived>&>(r_);
    //some logic that resizes r is here...
    Eigen::RowVectorXd xtx;
    //compute xtx here

    // and this fails:
    Eigen::VectorXd rsmall = r.derived().transpose().triangularView<Eigen::Upper>().solve(xtx);


The error probably has something to do with the way "r" is initialized,
I got lost in headers and could not figure out what is wrong.
Thanks.

The compiler error is
error: expected primary-expression before ')' token
error: no match for 'operator<' in '((Eigen::DenseBase<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >*)((Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>*)((Eigen::EigenBase<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >*)((Eigen::MatrixBase<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >*)r))->Eigen::EigenBase<Derived>::derived [with Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]()))->Eigen::DenseBase<Derived>::transpose [with Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]().Eigen::MatrixBase::triangularView [with unsigned int Mode = Mode, Derived = Eigen::Transpose<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >] < (Eigen::._83)2u'
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You need the template disambiguating keyword:

r.derived().transpose().template triangularView()

Another suggestion is to directly get the derived object of r:

Derived& r = _r.const_cast_derived();

and then no need to call r.derived(), directly use r.
bkot
Registered Member
Posts
11
Karma
0
Thank you.
Is the lower part of the matrix r destroyed when solve() is called?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
no, the lower part is simply skipped.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell