[eigen] Appending items in VectorXfs |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Appending items in VectorXfs
- From: Panos <panosy@xxxxxxxxx>
- Date: Thu, 10 Sep 2009 17:49:24 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Zfi3f+wj60Wng8lVtJYFA2U3u0Z2kjQXADI/2AULEhM=; b=hLW46ztVoROerCraa1sAQovCYIWaq/YCypmHm7haOmR2Q+8DDVgVd1d+3i4lqEQEio P+1thEcvnZ+W6UjPRh4ApSdU+JJPLZe2leaVn7Hbf5c/BlcjFkxb6xDkTFxh0Ufo+J1E WO6wPleoe5L4lHL9+Gt70/CQ2b20y5vAkJ+tA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=MolPiWnUGczN8zREotDlNyeIH3LAt1phYqF22EIs48578WU0hUR5i3348f6c0Ncw7f lVS4eMFuoXPR4T6Uj8wYgHJ68/9hOxZIir4vtAHLEq5P4Hk9Mq+BLumRtKKNvTuv60m8 c0IIvzVhl8EPlvdbTlJKItFde8TwFzc1G68Ew=
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