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

Zero size VectorXd initialization

Tags: None
(comma "," separated)
kerryloux
Registered Member
Posts
6
Karma
0

Zero size VectorXd initialization

Tue Dec 24, 2013 2:44 am
Hello all,

I'm new to Eigen. One of the requirements for my application is that matrix dimensions are allowed to be zero. After some quick tests under Windows (MSVC 2010), I was pleased to find that Eigen works just fine in this regard.

Unfortunately, gcc gives the following compilation error: call of overloaded ‘Matrix(int)’ is ambiguous

This is the line that produces the error:
Code: Select all
VectorXd v(0);// Works fine under Windows, fails to compile with gcc


Changing the argument to 1 (or presumably any other integer > 0) solves the compilation issue, but of course this doesn't really solve my problem.

Any insight into what is causing the issue? Is there something to which the zero can be cast to resolve the ambiguity?

Thanks and happy holidays,

Kerry
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You can simply declare an empty vector as VectorXd v; or disambiguate with VectorXd v(std::ptrdiff_t(0));.
kerryloux
Registered Member
Posts
6
Karma
0
Ahha - the default constructor seems so obvious now...

I never would have guessed that casting to std::ptrdiff_t would work, though. Thanks for your help!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]