[eigen] How to raise double to array powers in Eigen

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

cross-posted to stack overflow...

I have a very simple problem that should have a simple answer as well, but so far no luck.

I need to raise a double value to an array of integer powers, in c++ this would look something like

    for (int i = 0; i < N; ++i)
        y[i] = pow(delta, l[i]);

But in Eigen I have tried a number of variants on this theme, without success.

I have an Eigen::ArrayXi l_intE which maps an STL vector l_int.

This doesn't work:

    Eigen::pow(double, l_intE)

since the pow() function wants an array as the first input, and then to raise the array to a constant power.

One nasty workaround that I was able to get working (this can't be the right way) is to do this:


which does the conversion

    pow(delta,L) -> exp(L*log(delta))

and I also have to convert the integers to doubles. This can't help performance either since pow(double, int) is significantly faster than pow(double, double) in general. Although, maybe that isn't true with SSE in Eigen?

Anyway, clarity here would be greatly appreciated.

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