[eigen] Appending items in VectorXfs

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi all,

probably a basic question, just don't seem to find any answers in the docs. I need to efficiently append items to a dynamic vector, let's say, a VectorXf item. In loop, for each iteration expand the VectorXf by size 1, adding an element in its end, kind of like the matlab command:

x=[];
for i=1:10,
   x = [x i]; %appending i at the end of x
end

It can be done by allocating a tmp of size x.size()+1 in each loops and copying there, adding the element and copying back to x, but is nowhere near optimal so I wonder if it can be done with an Eigen function or in a better/faster way?

thanks!
panos


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/