help-octave
[Top][All Lists]
Advanced

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

Re: 3D array


From: Jonathan King
Subject: Re: 3D array
Date: Fri, 16 Nov 2001 11:31:57 -0600 (CST)

On Fri, 16 Nov 2001, John W. Eaton wrote:

> On 16-Nov-2001, Paul Kienzle <address@hidden> wrote:
>
> | What I have seen of matlab's nD array processing is that it is inconvenient
> | at best.  The linear algebra functions all expect matrices, so having 
> grabbed
> | a slice you must collapse it to a matrix before operating on it.
>
> It seems that this is only needed in some cases.  For example, I see
> that for
>
>   a = rand (3, 3, 3);
>
> the expression
>
>   svd (a(:,:,1))
>
> produces a result, but
>
>   svd (a(1,:,:))
>
> doesn't.  So it seems that considering the result to be a matrix works
> if the slice is in the "x-y plane" of the Nd object.  I don't see this
> as necessarily bad.

It's reasonable if you're using 3-d matrices as a data structure to store
multiple (2-d) matrices, which is a very common case in Matlab.  It does
get a bit more annoying if you're using 3-d matrices to store 3-d (e.g.,
volumetric) data, or 4-d (e.g., volumetric time series) data.
Presumably, the "correct" way to handle those kinds of cases if you were
doing it a lot would be to do a thorough object-oriented treatment of the
data structure.

Being the lazy guy I am, I have to admit that what I did was to quickly
create a bunch of wrappers (svd3, for example) that just do the
appropriate squeezing for me before handing off to svd and only whine when
the result of the squeeze makes no sense as input for the function in
question.

jking




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