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

[SOLVED] new Vector2f[...] failing

Tags: None
(comma "," separated)
questor
Registered Member
Posts
2
Karma
0

[SOLVED] new Vector2f[...] failing

Fri Mar 27, 2009 11:58 pm
Hi guys,

I'm not sure which version I'm using, but I think Eigen2-stable.

I have the following code:

Eigen::Vector2f *temp;
temp = new Eigen::Vector2f[bufsize/sizeof(POINTFX)];

and the visual-studio-2005-compiler responds with:

d:codinginsubversionistladdonseigen2srccorematrix.h(353) : error C2039: 'THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE' : is not a member of 'Eigen::ei_static_assert'
with
[
condition=false
]
d:codinginsubversionistladdonseigen2srccorematrix.h(350) : while compiling class template member function 'Eigen::Matrix::Matrix(const float &,const float &,const float &)'
with
[
_Scalar=float,
_Rows=2,
_Cols=1
]


when I look at the source-line of the assertions it's here:

/** constructs an initialized 3D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
m_storage.data()[2] = z;
}

which is strange, because it's using the constructor of the 3-dimensional-vector?!?

(and as a sidenote in the matrix.h the constructor for the 2-dim-matrix is not templated by "Scalar" but two ones, one with float and one with double; I think this is also a minor bug; this is how I suppose it should look:
/** constructs an initialized 2D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 2)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
}
)

any thoughts?

Last edited by ggael on Tue Mar 31, 2009 2:10 pm, edited 1 time in total.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

RE: new Vector2f[...] failing

Sat Mar 28, 2009 4:17 am
wow, MSVC is really wonderful ! The only solution I see is to try using malloc or a std::vector instead of new.

about the 2D constructor, the problem is that we also need a Matrix(int, int) ctor and so when Scalar==int we'd have twice the same ctor....
User avatar
bjacob
Registered Member
Posts
658
Karma
3

RE: new Vector2f[...] failing

Sat Mar 28, 2009 6:43 am
Maybe try with MSVC 2008 ?

Another option might be to replace your array of Vector2f by a single matrix of type

Code: Select all
Matrix


which would have the additional advantage of allowing certain operations to get vectorized (although with MSVC vectorization happens only with 2008)


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

RE: new Vector2f[...] failing

Sat Mar 28, 2009 12:46 pm
okay, I've found out why msvc acted like that, for the records:

I had code looking like this:

Eigen::Vector2f *temp;
temp = new Eigen::Vector2f[100];
...
temp[0] = Eigen::Vector2f(0.0f, 0.0f, 0.0f);

so the wrong constructor was used because of the Vector2f with 3 floats...

anyway, thanks for you support :)


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell