Registered Member
|
If I'm returning by value a large MatrixXd object from a function, is the data copied (with overhead) or is there some return value optimization without copying, e.g. doing
I'm trying to trace the slowness of some code returning largish matrices (~10K cells) compared with faster C code that is based on pointers, and thought this might be a potential cause. |
Moderator
|
That depends on both your function and how it is used. In some case the compiler is able to get rid of the extra temporary. This is called Returned Value Optimization: http://en.wikipedia.org/wiki/Return_value_optimization. Eigen does not do anything special here.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]