Re: [eigen] Why doesn't DenseBase have a .cast member function?

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


BTW, I forgot to keep this thread update, but in the devel branch I've moved all the common unary operator methods to DenseBase. So now DenseBase does have a .cast method.

Shall we backport it to 3.3? (seems harmless)

gael

On Fri, Dec 30, 2016 at 11:02 AM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:
Good point. I don't see any reason for not moving plugins/CommonCwiseUnaryOps.h from ArrayBase/MatrixBase to DenseBase. (the file CommonCwiseUnaryOps.h is where cast all all other common coefficient-wise unary methods are declared).

I guess that it is currently included in ArrayBase/MatrixBase because of the symmetry with "plugins/CommonCwiseBinaryOps.h", this one cannot be moved to DenseBase because binary operators are only valid between expressions of the same kind (e.g., array+matrix is forbidden).

Anyway, it is usually not recommended do directly deal with objects of type DenseBase<Derived>, better cast them to Derived first:

template<typename Derived>
void foo(const DenseBase<Derived> &_arg) {
  const Derived &arg(_arg.derived());
  ...
}

gael

On Fri, Dec 30, 2016 at 12:56 AM, Alec Jacobson <alecjacobson@xxxxxxxxx> wrote:
ArrayBase and MatrixBase do. Does this have something to do with expressions?





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