Re: [eigen] API addition: resizeLike(const Mat & other);

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


I vote for resizeLike()

gael

On Mon, Feb 2, 2009 at 1:43 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2009/2/2 Keir Mierle <mierle@xxxxxxxxx>:
>> I propose adding .resizeLike(const mat &other) which resizes *this to
>> be the same size as other. I find this is something I do fairly often,
>> and there is precedent in numpy (empty_like(), zeros_like,
>> ones_like()).
>>
>> Any objections? If not, I'll send a patch.
>>
>> Alternately: we could overload .resize() to take a matrix argument.
>> That may be misleading; I could be convinced either way.
>
> +1 to the idea, and I also don't know what I prefer.
>
> In either case, please take care of the vector case as we already do
> in resize(int).
>
> Actually you could leverage what we already do in resize(int):
> resizeLike(other)
> {
>  if(IsVectorAtCompileTime)
>    resize(other.size());
>  else
>    resize(other.rows(), other.cols());
> }
>
> Cheers,
> Benoit
>
>
>



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