help-octave
[Top][All Lists]
Advanced

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

Re: resize


From: David Bateman
Subject: Re: resize
Date: Wed, 30 Jul 2008 18:13:38 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080725)

Francesco Potorti` wrote:
What does the resize function do?

Its help string makes one think that it does the same as reshape, only
in place:
 -- Built-in Function:  resize (X, M, N)
     Destructively resize X.

     *Values in X are not preserved as they are with `reshape'.*

     If only M is supplied and it is a scalar, the dimension of the
     result is M-by-M.  If M is a vector, then the dimensions of the
     result are given by the elements of M.  If both M and N are
     scalars, then the dimensions of the result are M-by-N.

     See also: reshape.

However, it does not do that:

octave> resize((1:3*4)',[3 4])
ans =

   1   0   0   0
   2   0   0   0
   3   0   0   0

Is it a sort of truncation?

It seems to do what it says it does to me.. That is in your example it takes a 12x1 matrix and converts it to a 3x4 matrix keeping the overlapping parts of the matrix assuming that the [0,0] index is the same.

The original reason this function was created was that some user types might have additional attributes associated with them and so a zeros(m,n) couldn't be used in many functions, but a resize(resize (x, 0, 0), m, n) could and keep the attributes of x. An example is the primitive polynomial of a galois field user type.

Regards
David

--
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



reply via email to

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