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

How to efficiently copy double * from/to matrix

Tags: None
(comma "," separated)
wingsit
Registered Member
Posts
28
Karma
0
OS
Hi all,

I am evaluation eigen for future project. One simple question that I cannot figure out is how one can fill a matrix give an array of double (in column/row major order).

Any pointer is appreciated.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Use the Map class to map your existing double* array as a Eigen expression.

http://eigen.tuxfamily.org/dox/classEigen_1_1Map.html

EDIT: hm OK the documentation there isn't too friendly so have a look at the tutorial:
http://eigen.tuxfamily.org/dox/TutorialCore.html
(search for "Map" in that page)


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
wingsit
Registered Member
Posts
28
Karma
0
OS
Nice, that helps.

One more follow up question. Suppose that the memory buffer is not cache aligned with the eigen standard, would the vectorisation still be performed?

Thanks.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
For dynamic-size expressions (for example Map<MatrixXf>), yes. Eigen will then, at runtime, do the first few scalars separately until the first 16-byte-aligned location, and will continue with SIMD packets from there on.

For fixed-size expressions (for example Map<Matrix4f>), no.

If you happen to know that the pointer is 16-byte aligned, then, with the development branch (not Eigen 2.0) you can tell that to Eigen: Map<Matrix4f, Aligned>.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]