[eigen] Array question (maybe a bug)

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


Is this expected?

#include "Eigen/Core"
#include "Eigen/Array"

using namespace Eigen;

int main() {
    VectorXd y(3);
    double rams=1.25;
    VectorXd kk(4);
    kk << 0.1, -0.1, -0.1, .1;
    y    =  rams-kk.array();        // Wrong answer 
    //y  =  -kk.array()+rams;    // OK 
    for (int i=0; i<4; ++i) {
        std::cout << y[i] << "\t" << (rams - kk[i]) << std::endl;   
    }
    return 0;
}

Returns, where I was thinking they would be equivalent.

tirons@baboon:~/sandbox/eigen$ ./min
-1.15    1.15
-1.35    1.35
-1.35    1.35
-1.15    1.15

I get the expected answer with   -kk.array() - rams.
Is this a bug, or am I missing something with how array's work?

Thanks,
Trevor


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