octave-maintainers
[Top][All Lists]
Advanced

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

What is the expected behaviour of resize of NDArrays?


From: John W. Eaton
Subject: What is the expected behaviour of resize of NDArrays?
Date: Tue, 20 Apr 2004 09:44:24 -0500

On 20-Apr-2004, David Bateman <address@hidden> wrote:

| I have a problem that causes fft([1,2]',1) to crash for which a patch
| is attached. However, while checking into this problem I identified a
| strange difference in behaviour of resize_no_fill and resize_and_fill
| in Array.cc. The code
| 
| dim_vector dv;
| NDArray a;
| ...
| a.resize (dv);
| 
| Causes the random data to be placed at the end of a considered as a 
| single index if dv is larger than a.dims() is some dimension. Whilst,
| if dv is smaller than a.dims() is some dimension then it cut from the
| end. This means that a = [1, 3; 2, 4]; when resized to [1,2] becomes
| [1, 2] !!!
| 
| This is different than the behaviour for a.resize(dv, fill_value), which
| respects the dimensioning of the previous array.

I think they should both do the same thing except that the _no_fill
version should leave any new elements outside the bounds of the
original array undefined.  So it looks like there is a bug in the
current version of resize_no_fill.

jwe



reply via email to

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