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

The Map behavior

Tags: None
(comma "," separated)
dhlin
Registered Member
Posts
18
Karma
0

The Map behavior

Thu Jul 07, 2011 6:56 pm
First of all, thanks for all the great efforts to bring forth such a great library.

I am working on a C++ project that involves intensive computation related to computer vision and machine learning, and considering leverage the performance and convenience provided by Eigen.

In this project, there are several different libraries. To cooperate with them, I may rely on Eigen's Map class. I am wondering what is the underlying behavior of the mapping. Does it copy all data into an internal representation? or does it just serve as a light wrapper that simply referring to that memory address? or does it do some "smart" things that automatically determine when(or whether) to copy?

Another question: Is is allowed to construct a Matrix object with an Map object? (I assumed yes ..) If so, does the construction performs a deep copy? Thank you.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: The Map behavior  Topic is solved

Thu Jul 07, 2011 10:00 pm
A Map only stores references to external memory. On the other hand a Matrix<> object always has its own memory.

double *data = ..;
Map<MatrixXd> m(data,rows,cols);

m = 2*m; // this uses and modifies data

MatrixXd A = m; // deep copy
dhlin
Registered Member
Posts
18
Karma
0

Re: The Map behavior

Fri Jul 08, 2011 3:12 am
Thanks for the clarification.


Bookmarks



Who is online

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