help-octave
[Top][All Lists]
Advanced

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

Re: is_complex_nd_array() ?


From: Max Brister
Subject: Re: is_complex_nd_array() ?
Date: Thu, 16 Aug 2012 22:53:03 -0500

On Thu, Aug 16, 2012 at 7:27 PM, jjg <address@hidden> wrote:
> I am sorry to keep on about this
>
>
> Max Brister wrote
>>
>> What you have here is an octave_value containing a Matrix (which is
>> also an NDArray).
>>

I tried to over simplify things. In the octave source there are two
type hierarchies. The first is as you expect, Matrix inherits from
MArray[1]. Then MArray inherits from NDArray[2]. Matrices are two
dimensional MArrays. MArrays add math operations to NDArrays.

In the interpreter values are kept track of in subclasses of
octave_base_value. In this case, we have a class octave_matrix that
holds a NDArray[3].

> No, what I have in an N-dimensional array which might be a matrix.
> A 3 dimensional array is not a matrix, a 2 dimensional array is a
> matrix.  The set of N-dimensional arrays includes the 2-dimensional
> arrays so it includes the matrices.  Were the function is_nd_array()
> to exist then it would be right and proper that it return true for a
> matrix. Since a matrix is an N-dimensional array.

Here is_real_matrix is checking to see if you octave_value contains an
octave_matrix object. As octave_matrix contains NDArrays, this returns
true for N>2.

> But it is borderline insane that is_matrix(A) is true for an N-dimensional
> array with N>2, when anyone in the street will tell you that it should be
> false.  Absolutely bonkers.

I don't think this is complete insanity. It's a minor mistake in
naming at the worst. It is also interesting to note that originally
octave_matrix was called octave_nd_array (this is where the
is_real_nd_array function came from).

> The octave dev team can do as they wish of course.  Perhaps
>
>   #define TRUE FALSE
>
> or
>
>   #define malloc(x) free(x)
>
> in a global header file would be fun.
>

If you really feel so strongly about the issue (and want to work on a
patch) you can bring it up on the octave-maintainers list.

[1] 
http://hg.savannah.gnu.org/hgweb/octave/file/8367f326fa29/liboctave/dMatrix.h#l34
[2] 
http://hg.savannah.gnu.org/hgweb/octave/file/8367f326fa29/liboctave/MArray.h#l38
[3] 
http://hg.savannah.gnu.org/hgweb/octave/file/8367f326fa29/src/octave-value/ov-re-mat.h#l50

-- 
Max Brister


reply via email to

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