|Re: [eigen] Appending items in VectorXfs|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Appending items in VectorXfs
- From: Panos <panosy@xxxxxxxxx>
- Date: Thu, 10 Sep 2009 18:59:50 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=zK31rLk4sx4Ctv5XgMhgaLD3tAeoz3ttqZmmWuBdqOQ=; b=odd0T5xKJ/HIN6ckpKmeZwnnBksmEj2NZAMwmhGIDW7KSkufMLxEdttDH+W88tSQZI OZFDoS6u7SOzn/0CP3KIkvzf+/jwWI991RgcpzzoSI+G2r+Fk83ZiSd3gcUrsY4MZiRo xHg2F5XtOACkKYis1RESclATD16vObStXbins=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=JQqWO2bHB0DjsHjOI8YD8CMpnxy2E86fIlaTHDhVLMCBbatPr272C+lCb/5raHjV76 e9+EVFq8KnVTfooM7O1m6pq/h14bUMmg7gKeANvWFQwb2HbaRJ7pSLHVpG5l30mVV4LW pJG4ziL1XuJ9dMBKIv1Em/lC/s7EXJDOtPoqQ=
Hm, feel kind of stupid about this, Eigen appears to have a method resize() for those types, that works great. For some reason it is not mentioned in the core documentation, or I couldn't find it anyway. Still, thanks everybody for the answers :)
On Thu, Sep 10, 2009 at 6:54 PM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
With the default (development) branch you can do something like this
const int old_size = x.size();
// x.conservativeResize(old_size+10); // this is much (!) better...
x.conservativeResize(old_size+1); // not so good...
x(old_size+i-1) = i;
It is obviously much better to do the resizing just once in case you
know how many elements you will be appending...
On 9/10/09, Rohit Garg <rpg.314@xxxxxxxxx
>> 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
>> optimal so I wonder if it can be done with an Eigen function or in a
>> better/faster way?
> I doubt that. :(
> Rohit Garg
> Senior Undergraduate
> Department of Physics
> Indian Institute of Technology