lundi 30 juillet 2018

Fastest way to repeat a vector in Eigen c++

I have two vectors:

Eigen::Array2d A;
Eigen::Array4d B;

Basically, the vector A contains some value like

0.3
0.7

The idea is that I would like to get the vector B as follows

0.3
0.3
0.7
0.7

What is the fastest way to do that? I want the "fastest" way because I have to do this manipulation a lot of times. I know that I could use a mixture of replicate, transpose(), and Map functions to do it but it won't be so fast.

Should I use pointers, instead? Let's say the first two rows of B would point to the first row of A, and the two last rows of B would point to the last row of A? Does it make sense?

Aucun commentaire:

Enregistrer un commentaire