This forum has been archived. All content is frozen. Please use KDE Discuss instead.

problem with setones

Tags: None
(comma "," separated)
baltcode
Registered Member
Posts
12
Karma
0

problem with setones

Sat Jan 16, 2010 11:08 pm
Hi
I am having trouble setting all ones in a very simple matrix.

Code: Select all
        int N=10;
        Eigen::MatrixXd vun;
        vun = Eigen::MatrixXd::Ones(N,1);
        std::cout<<"vun = "<<vun<<"\n";

gives the following output
vun = 2.122e-314
2.122e-314
1
1
1
1
1
1
1
1


Interestingly, if I try the other method:
Code: Select all
        int N=10;
        Eigen::MatrixXd vun(N,1);
        vun.setOnes();
        std::cout<<"vun = "<<vun<<"\n";


I again get
vun = 2.122e-314
2.122e-314
1
1
1
1
1
1
1
1


However, if I use both, I get the correct answer.
Code: Select all
        int N=10;
        Eigen::MatrixXd vun(N,1);
        vun = Eigen::MatrixXd::Ones(N,1);
        vun.setOnes();
        std::cout<<"vun = "<<vun<<"\n";

This gives:
vun = 1
1
1
1
1
1
1
1
1
1


Any idea what's going on?
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: problem with setones

Sat Jan 16, 2010 11:15 pm
This is very strange... what eigen version and compiler are you using? Can you also give a compilable test program and the exact compilation command line / settings used?


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
baltcode
Registered Member
Posts
12
Karma
0

Re: problem with setones

Sun Jan 17, 2010 3:03 am
Ok, so I tried running it on a different computer, and the problem only occurs with a certain configuration. It happens on a Mac OSX 10.5, with Eigen version 2.0.0 installed through MacPorts. The compiler used was gcc v 4.5.

It does not happen on my other computer, a 64 bit Ubuntu with Eigen v 2.0.5, and gcc v 4.4.1.

Here is the complete code:
Code: Select all
#include <iostream>
#include <eigen2/Eigen/Core>
#include <eigen2/Eigen/Array>



int main() {
        int N=10; int K=3;

        Eigen::MatrixXd vun(N,1);
        //Eigen::MatrixXd vun;
        //vun = Eigen::MatrixXd::Ones(N,1);
        vun.setOnes();
        std::cout<<"vun = "<<vun<<"\n";

}


I use the "//" comments to select which method (ones or setones) to use. I still think we need to find out what's going on, and perhaps the Eigen Macport needs to be updated.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: problem with setones

Sun Jan 17, 2010 3:07 am
Eigen 2.0.0 was the initial release and a lot of bug fixing followed: that is the 2.0.x releases. If it works with 2.0.5 this probably means that it's already fixed. Can you reproduce the bug on any configuration with the latest Eigen 2.0.11 ? If no, I consider the issue solved... ;)

Macports does have 2.0.11:
http://www.macports.org/ports.php?by=li ... bstr=eigen


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
baltcode
Registered Member
Posts
12
Karma
0

Re: problem with setones

Sun Jan 17, 2010 3:33 am
Thanks for the update on Eigen 2.0.11. I installed it via MacPorts, and it seems that I get the correct result with gcc 4.3 or earlier, but the wrong result with my copy of gcc 4.5. There is another release of the gcc 4.5 available, so I will see if that solves the problem. However, it seems the problem is with gcc 4.5 (which is a pre release beta).
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: problem with setones

Sun Jan 17, 2010 4:05 am
OK, GCC 4.5 being not yet released, this is perhaps not worrying. Also, I have a build from november 26 and it works for me. That said, we are aware of GCC 4.5 bugs affecting Eigen and GCC devs are very responsive fixing them.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42225
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42450


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
baltcode
Registered Member
Posts
12
Karma
0

Re: problem with setones

Sun Jan 17, 2010 2:03 pm
Yes, since gcc 4.5 is still pre-release I guess its not an issue. Just for the record in case someone is interested, it repeats in gcc 4.5 Jan 14th build.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]