octave-maintainers
[Top][All Lists]
Advanced

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

Re: reshape behavior


From: Rik
Subject: Re: reshape behavior
Date: Mon, 11 Nov 2013 16:18:38 -0800

On 11/11/2013 03:28 PM, John Donoghue wrote:
On 11/11/2013 05:22 PM, address@hidden wrote:
Message: 6
Date: Mon, 11 Nov 2013 13:31:10 -0800 (PST)
From: PhilipNienhuis <address@hidden>
To: address@hidden
Subject: Re: Matlab reshape behavior
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Rik-4 wrote
> 11/11/13
> 
> Could someone verify what Matlab does with a single input to reshape?
> 
> --- Code ---
> x = 1:3;
> y = reshape (x, 3)
> --- End Code ---
> 
> Octave running on Linux expands the the '3' to '3x1', but Octave running
> on
> MinGW interprets '3' to be '3x0'.
3 x 0?  Not here:

>> x = 1:3
x =

   1   2   3

>> y = reshape (x, 3)
y =

   1
   2
   3

>>
(I think an MXE build based on changeset 17894:62b76b377749 (or around that
time, anyway from Sunday), on WinXP)

Philip



Octave cross compiled on Fedora box, and running on Windows 7:

 

>> x = 1:3;y = reshape (x, 3)

error: reshape: can't reshape 1x3 array to 3x0 array

>> 

 

Octave native compiled and run on the same Windows 7 machine:

>> x = 1:3;y = reshape (x, 3)

y =

 

   1

   2

   3

 

>> 

 

Both were checked out around the same time Saturday dev octave 3.7.7+ . I am now rebuilding the cross compiled version and all of mxe-octave today and will rerun it.
11/11/13

All,

It seems that we have been relying on undocumented behavior of reshape that is sometimes changeable and certainly not Matlab-compatible.  Probably the best course of action is to fix ndgrid so that it calls reshape properly.  As a second step, it might be nice to improve the input validation of reshape to catch when it is called improperly.

--Rik

reply via email to

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