Re: [eigen] matrix::linspace

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


On Mon, Jan 25, 2010 at 7:50 PM, Ricard Marxer Piñón
<email@xxxxxxxxxxxxxxxx> wrote:
> Thanks for this work, this will be really useful, at least for me for sure.
> I haven't checked if this is done or not yet, but it would be really
> nice to have a class that allows us to do:
>
> VectorXf::LinSpace(0, 10, 100)

In principle this is done. What you are asking for is just a shortcut for

VectorXf::NullaryExpr( 100, ei_linspace_op<Scalar>(0,10,100) );

I just did not yet add the shortcut. I am a bit reluctant since currently

VectorXf a;
a.setLinSpace(0,10,100);

and

VectorXf a = VectorXf::NullaryExpr( 100, ei_linspace_op<Scalar>(0,10,100) );

have different run-times (when vectorization/SIMD is enabled) though
the same semantics. For the shortcut you are requesting we need to
ensure that random access of vector elements is possible. In the first
case on the other hand side we are basically recreating a vector and
thus can take advantage of sequential element access. One might
circumvent the problem by adding a template parameter e.g.

VectorXd::LinSpace<Sequential>(0,10,100);

but I am not yet sure and IIRC default template parameters are not
possible for member functions.

> Doest this make sense?

Absolutely... and it will most likely come.

- Hauke



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