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

new on Matrix4f in struct fails

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

new on Matrix4f in struct fails

Sat May 26, 2012 12:57 pm
Hi!

I have a question to 'new' operator on structs including Matrix4f matrices.
Here is my code:

Code: Select all
struct ProcessedImage
{
    ProcessedImage(): m_framenumber(-1) {}

  int m_framenumber;

    Eigen::Matrix4f result;
    Eigen::MatrixX3f *m_point_cloud;
};

     ProcessedImage *p2 = new ProcessedImage();  // this fail!!!


It works fine for Matrix3f but fails on Matrix4f. Any idea why so?
Regards
FMD
Registered Member
Posts
25
Karma
0

Re: new on Matrix4f in struct fails

Sat May 26, 2012 6:17 pm
Hi, (just to give you a quick but not neccessarily profund answer)

Matrix4f is a fixed size defined matrix ("typedef Matrix< float , 4 , 4 > Matrix4f")
MatrixX3f is a dynamic size defined matrix ("typedef Matrix< float , Dynamic, 3 > MatrixX3f")

(please note the extra "X" in the type name)

Cheers
hannes_waldner
Registered Member
Posts
2
Karma
0

Re: new on Matrix4f in struct fails

Sat May 26, 2012 6:55 pm
FMD wrote:Hi, (just to give you a quick but not neccessarily profund answer)

Matrix4f is a fixed size defined matrix ("typedef Matrix< float , 4 , 4 > Matrix4f")
MatrixX3f is a dynamic size defined matrix ("typedef Matrix< float , Dynamic, 3 > MatrixX3f")

(please note the extra "X" in the type name)

Cheers


Hi!

Yea, i know the "X" denotes a dynamic Matrix. The app does not hang because of the pointer MatrixX3f*!
Reduced (also crashing) code:
Code: Select all
struct ProcessedImage
{
    Eigen::Matrix4f m_gicp_result_transformation2;
};

ProcessedImage *p2 = new ProcessedImage(); <- crash ( "R6010" abort has been called)


It seems to be strange! Because the storage for Matrix4f should be IMHO also
known at compile-time. I can not see a problem in this case?!?

I'm using Visual Studio 10 and newest Eigen-lib.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Read this page:

http://eigen.tuxfamily.org/dox-devel/To ... mbers.html

in short you need to add EIGEN_MAKE_ALIGNED_OPERATOR_NEW in the body of your class.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell