Re: [eigen] Bug in pow function

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


Indeed, the double 'del' was implicitly converted to a 'int' by the compiler to match the following overload: pow(Derived::Scalar,const Array<Scalar>&). I've removed it so that we have full control on such type conversion/promotion: https://bitbucket.org/eigen/eigen/commits/c3f7832726ca

It now fails to compile, just like del*i. If we want to enable it, it's just a matter of specializing ScalarBinaryOpTraits<>.

gael

On Sun, Jun 11, 2017 at 2:46 AM, Ian Bell <ian.h.bell@xxxxxxxxx> wrote:
I think I have identified a bug in the Eigen::pow function:

double del = 1.3;

Eigen::ArrayXi i(4); i << 1,2,3,4;

Eigen::ArrayXd d(4); d << 1.0,2.0,3.0,4.0;

    

std::cout << d << ": " << Eigen::pow(del, d) << std::endl;

std::cout << i << ": " << Eigen::pow(del, i) << std::endl;


yields


1

2

3

4:    1.3

  1.69

 2.197

2.8561

1

2

3

4: 1

1

1

1


where the pow(double, int) results are all 1, which is incorrect.




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