Re: [eigen] conservative resize ... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] conservative resize ...
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Mon, 7 Sep 2009 14:24:02 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=9pX2LxsIKJ5YLDjdcUfBsTJx2ORdmXjmiwsaClQHH7Q=; b=QMXwZcI5Wt1qNWH3cOGbEm+yG9AMIrWTq5yyp1pjaSzZPgBhjeQyRwT8Rp7TOZpv+9 pGRAxAO/YipAV/Nh1dPmbNJY3l5XJxrN9nCV3rsgMwkzFJBa28QSmbmMyeuycFP0tXpQ 6N3Y3iYrTCHiZF7sS8uTZ2tcWOMzYLp8eZIC8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=jDX1AckPTFSa6EsDCu96+z2+eTApE/WO4XV8y9+yxpTVeklP6nGSX2BySM8DM2rc3A cEmXP90iCFLru9G/Ji3ULhOpXJ+z6p9pHB4jVgl3n6Ag5FFq3RVk00zC/4OmTatSk/Hd 4nhjv6T2UZqansI8OnfhKNUC3mz/HN493pRbY=
I like it. +1
Following the naming of the already existing resizeLike we could call
it conservativeResizeLike ...
- Hauke
On Mon, Sep 7, 2009 at 2:13 PM, Gael
Guennebaud<gael.guennebaud@xxxxxxxxx> wrote:
> hi,
>
> what about the following:
>
> - we keep only the two simple conservativeResize() overloads taking
> only size arguments
>
> - we add one template overload:
>
> template<typename OtherDerived>
> void conservativeResize(const MatrixBase<OtherDerived>& other);
>
> resizing *this to match the sizes of other, and filling the extended
> parts from the respective parts of other. Typical use cases:
>
> Mat m;
>
> // ...
>
> // extend with 0 (similar to the current m.conservativeResize(r, c, true))
> m.conservativeResize(Mat::Zero(r,c));
>
> // extend with x:
> m.conservativeResize(Mat::Constant(r, c, x));
>
> // and some more complex examples:
> m.conservativeResize(Mat::Identity(r,c));
> m.conservativeResize(Mat::Random(r,c));
>
> The drawback is that it makes the "extend with zeros" a bit more verbose.
> Alos, perhaps conservativeResize() is not a very good name for this
> overload, but what do you think about this idea ?
>
> cheers,
> gael.
>
>
>
> On Mon, Sep 7, 2009 at 1:52 PM, Hauke Heibel<hauke.heibel@xxxxxxxxxxxxxx> wrote:
>> On Mon, Sep 7, 2009 at 1:34 PM, Márton Danóczy<marton78@xxxxxxxxx> wrote:
>>> You're right, initializing a matrix after resizing should suffice, if
>>> it is not slower than doing both in one step.
>>
>> It is possible and would probably be even faster - if done correctly.
>> I am just saying this because you would need to take care of
>> initializing only those parts of the matrix which are yet
>> uninitialized. At the moment, when pre-initializing with zeros, the
>> parts of the old and resized matrices that overlap are accessed twice.
>> Once for initializing with zeros and a second time to copy the old
>> values.
>>
>> @Benoit, ExtendByZero is fine. I am just wondering, was there a
>> particular reason for making NoChange_t a struct? Should we follow the
>> same strategy to ExtendByZero?
>>
>> - Hauke
>>
>>
>>
>
>
>