Re: [eigen] Passing result of block() as non-const reference-to-matrix?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2010/7/9 Sidney Cadot <sidney.cadot@xxxxxxxxx>:
> Hauke, Martin: thanks for your suggestions.
>
> It's a pity that there is no clean solution that is portable to pre-C++0x.. I still don't quite get that it does work as expected when I pass a const Block to a const Matrix & -- it is not clear for me why that /does/ work.

That does /not/ work :-) Try it, try to pass a Block as a const
Matrix&, it won't compil, since these are different types. On the
other hand, passing a Block as a template<typename T> const
MatrixBase<T>& will work, because (in the matrix case) Block inherits
MatrixBase<Block>, so the compiler will be able to resolve T=Block.

>
> I have a feeling that I (as an API user) need to know too much about the intricacies of the Eigen data-structures in this case, while I can usually just really on stuff to (almost magically) work; A Matrix::block() result /usually/ returns something that behaves as Matrix, but not always.

Expression templates come at the cost of some complexity, need the
user to understand some concepts. It's true. But it's worth it, so
it's a documentation issue.

Documentation ninjas: this is the reason why I believe we really need
to end the tutorial on one page explaining the vital minimum stuff to
know about base classes, passing Eigen objects to functions, etc.

Benoit

>
> Best regards, Sidney
>
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/