Re: [eigen] CRTP in eigen: using .derived() |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hi folks,
I have a question concerning the CRTP base classes in eigen, for instance
Eigen::MatrixBase. In most examples of generic functions in the documentation,
I see something like this:
template <class Derived>
void do_smth(const Eigen::MatrixBase<Derived>& mat) {
const double det = mat.derived().determinant();
}
My question is about the mat.derived(), is that necessary?
If I understood crtp correctly, than mat.determinant() should do exactly the
same (provided the base class implements this function).
Are there advantages of using .derived() when constructing expressions?
I could imagine that it makes a difference whether one does e.g.:
return mat.block(...);
or:
return mat.derived().block(...);
as the types will be different, but I have no idea what the actual impact is.
Thanks in advance,
Dan
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |