help-octave
[Top][All Lists]
Advanced

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

Re: `size' and trailing singleton dimensions


From: David Bateman
Subject: Re: `size' and trailing singleton dimensions
Date: Tue, 1 Jun 2004 10:03:36 +0200
User-agent: Mutt/1.4.1i

The N-D stuff is a moving target, that is trying to implement this
stuff correctly. If you tried the CVS version of octave, you'd find 
that the case you cite is already fixed...

D.

According to Peter J. Acklam <address@hidden> (on 05/31/04):
> I use N-dimensional array manipulation heavily in MATLAB, but
> switching to Octave I run into many problems.  Trying to
> understand this from the ground up, I have a few questions:
> 
> Why does Octave treat trailing singleton dimensions differently
> than MATLAB, even when the `--traditional' switch is used?
> 
> It seems that trailing singleton dimensions matter in some cases,
> but not in others.  For instance, `size' does care about them, but
> `ndims' doesn't:
> 
>    >> x = rand(5, 7);
>    >> size(x, 2)
>    ans = 7
>    >> size(x, 3)
>    error: size: requested dimension (= 3) out of range
> 
> For the above call to `size' to work, I would have to include a
> trailing singleton dimension:
> 
>    >> x = rand(5, 7, 1);
>    >> size(x, 3)
>    ans = 1
> 
> So `size' does not behave like MATLAB's `size'.  It also returns
> singleton dimensions when called with one argument:
> 
>    >> size(x)
>    ans =
> 
>            5        7        1
> 
> However, `ndims' ignores the trailing singleton dimensions:
> 
>    >> ndims(x)
>    ans = 2
> 
> As a consequence `ndims(x)' isn't necessarily equal to
> `length(size(x))' which it always is in MATLAB.
> 
> It seems inconsistent to me that `size' does care about trailing
> singleton dimensions, but `ndims' doesn't.  What's the logic
> behind this?  (I have read section 3, Data Types, but that doesn't
> mention this.)
> 
> Peter
> 
> -- 
> Peter J. Acklam - address@hidden - http://home.online.no/~pjacklam
> 
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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