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

Temporary variable allocation

Tags: None
(comma "," separated)
eigenuser_ag
Registered Member
Posts
1
Karma
0
OS

Temporary variable allocation

Thu May 31, 2012 11:48 pm
Hi,

I have the following piece of code. I was expecting a run-time error but did not get it. I was wondering if anyone has any inputs.

typedef Eigen::Matrix<double,6,6> Matrix6d;
Matrix6d P;
P << 10, 0, 0, 0, 0, 0,
0, 10, 0, 0, 1, 0,
0, 0, 10, 0, 0, 0,
0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1;
Eigen::internal::set_is_malloc_allowed(false);
P = P*P;
Eigen::internal::set_is_malloc_allowed(true);

My understanding is that P=P*P requires the creation of a temporary variable. I thought the temporary variable will be dynamically allocated on the heap. Hence I was expecting an error. Or is Eigen creating the temporary variable on the stack?

I appreciate any inputs. Thanks !

ps: I have defined the macro EIGEN_RUNTIME_NO_MALLOC in my code
jitseniesen
Registered Member
Posts
204
Karma
2

Re: Temporary variable allocation  Topic is solved

Fri Jun 01, 2012 10:44 am
Fixed-size matrices are created on the stack. If you use a dynamic-size matrix (MatrixXd), you do get a run-time error.


Bookmarks



Who is online

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