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

Dynamic Eigen::Matrix of 0x0 dimensions?

Tags: None
(comma "," separated)
Seb
Registered Member
Posts
99
Karma
0
H everybody,

I remember the discussion about allowing the construction of dynamic matrices of size 0x0. As I remember correctly, it is allowed in the development branch and should be in the latest 2.0.x release.

I even use it and it works well using 2.0.12.Now it came to the first time when I compiled without any debug symbols. This time it did assert on constructing Matrix(0,0)!!!?

Do you know any trick (for example #define-s) to allow 0x0 matrices in Eigen 2.0.x? What is the current state in the development branch? Is it finally allowed there? Or did the developer team decided against this feature? (That would mean we have to move from Eigen to somewhere else)

Thanks in advance.
Sebastian
Seb
Registered Member
Posts
99
Karma
0
Ok, I browsed the source code and found that the options

EIGEN_NO_DEBUG and NDEBUG

disable all asserts (sadly, no selective disabling possible?)

I also checked the trunk and it seems that the assert has been gone, but I can be mistaken since Matrix creation is more sophisticated there.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Seb wrote:I remember the discussion about allowing the construction of dynamic matrices of size 0x0. As I remember correctly, it is allowed in the development branch and should be in the latest 2.0.x release.


Yes, this is allowed in both 2.0 and the development branch, the syntax for that is to use the default constructor:
Code: Select all
MatrixXf m; // now m is a 0x0 matrix


I even use it and it works well using 2.0.12.


Yes, I re-checked, and with 2.0.12, as with the development branch, the above works, but passing explicitly the 0x0 size like this:
Code: Select all
MatrixXf m(0,0);

doesn't work. I believe that the reason was so we know at compile-time which matrices are 0x0. Is that OK with you (to have to use the first syntax above) ? Or is it important to allow also the 2nd one? Perhaps we should do that as it is a bit confusing, but it will result in one more if() at the creation of each dynamic-size matrix, resulting in a performance overhead.

So, is it OK for you to use the first syntax above?


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
Seb
Registered Member
Posts
99
Karma
0
Sure it is ok. I was not sure about default constructors - I actually never use them. Thanks for the reply. One more question, though:

In Eigen 3.0, will it be allowed to create, say Matrix(0,0), Matrix(i,0), Matrix(0,j) ? The latter 2 cases are often used in timeseries analysis as starting values of the samples.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
At the moment it's not allowed, but you're not the only one to ask for it, and I'm looking at these things. And it's indeed not intuitive that Matrix(0,0) is not allowed whereas Matrix() is. On the other hand, as I said, it's not easy to allow it without incurring a constant overhead. In the worst case it should be possible to add a separate constructor to build zero-size matrices while making it clear at compile time, by passing a special parameter of a special type, e.g. Matrix(ZeroSized, i, 0). I'll look at it...


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
Seb
Registered Member
Posts
99
Karma
0
I could live with and love such a solution. I agree that efficiency comes first and that the standard method should be in place.

Thanks for listening, Benoit!
User avatar
bjacob
Registered Member
Posts
658
Karma
3
No problem, actually I had a look at the code and at the moment I'm not sure I remember _why_ we didn't allow this. Improvements on this front may be coming...


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]