Registered Member
|
Is the fastest way to copy a large number of elements from one location to another to use block assignment?
For example, if I want to copy the contents of matrix m into vector v, is the best way to do this for (int i = 0; i < m.rows(); i++) v.block(i*m.cols(),0,m.cols(),1).transpose() = m.rows(i)? |
Moderator
|
In this case I'd suggest to re-map your data like this:
Matrix::Map(v.data(),m.rows(),m.cols()) = m; if m is row-major then the copy will be automatically vectorized. |
Registered Member
|
Thanks! |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]