help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About resize() function


From: Jaroslav Hajek
Subject: Re: About resize() function
Date: Fri, 24 Oct 2008 12:27:57 +0200

On Fri, Oct 24, 2008 at 11:50 AM, David Bateman
<address@hidden> wrote:
> Jaroslav Hajek wrote:
>>
>> OK, so what? I'm not saying that resize is not useful, I'm just saying
>> that
>> resize (x, m) should not mean the same as resize (x, m, m). resize
>> (zeros (3, 1), 4) should, IMHO, give zeros (4, 1), not zeros (4, 4) as
>> it gives now. That makes no sense to me.
>>
>>
>
> The test I gave is a test that is needed that justifies the existence of
> resize at all. Otherwise we could just use zeros() instead in tril/triu..
> Comparse to output of rand(4) and rand(4,1) .... Therefore in a certain
> logic (probably the one I use when I wrote resize) resize (arg, n) ==
> resize(arg, n, n) makes sense compared to the output of zeros(4), ones(4),
> rand(4), etc...
>

OK, that's a good point as well. I would, however, want resize to
match what Array<T>::resize does, and have the following invariant:
If, in indexed assignment A(ind) = X or A(ind(1), ind(2), ...) = X,
any of the indices contains an out-of range value, then A = resize (A,
dims) is executed first, where
dims is max (size (A), ext) and ext(i) = max (ind (i)) (this may
contain errors and is a little wordy, but I hope you get my meaning).

Thus, in accord with Array<T>::resize (and resizing on indexed
assignment), resize with a single dim spec will resize a vector. You
can get the current behaviour of resize (A, n) using resize (A, n, n)
which also seems more readable to me.
Resizing a vector, however, is not easily achievable using the current
resize (you have to check for orientation first).

Do you think that such a change to resize is worthwhile? I couldn't
find any code depending on this form of resize in current Octave's
sources.


> D.
>
>
> --
> David Bateman                                address@hidden
> Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) Parc Les
> Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 91193
> Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)
> The information contained in this communication has been classified as:
> [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola
> Confidential Proprietary
>
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]