octave-maintainers
[Top][All Lists]
Advanced

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

Re: Array API changes


From: Jaroslav Hajek
Subject: Re: Array API changes
Date: Wed, 24 Feb 2010 12:37:33 +0100

On Tue, Feb 23, 2010 at 12:25 PM, Jaroslav Hajek <address@hidden> wrote:
> hi all,
>
> I made the major changes to Array interfaces previously discussed on this 
> list:
> http://old.nabble.com/proposal-for-changing-Array-interface-td27253527.htm
>
> This is another significant step to a stable liboctave API:
> http://hg.savannah.gnu.org/hgweb/octave/rev/12884915a8e4
>
> The big picture:
> The Array class hierarchy in 3.2.x was unnecessarily complicated, with
> some classes of almost duplicate functionality (Array-Array2-ArrayN,
> MArray-MArray2-MArrayN).
> These are in fact relics, because Array<T> itself can handle both 2D
> and ND arrays, and any array can be treated as linear by linear
> indexing. There are no genuine 1D arrays in Octave. Using (n) as
> dimensions usually meant (n, 1) in liboctave, but sometimes (1, n)
> (e.g. resize). OTOH, in Octave it usually means (n, n). (e.g. zeros,
> ones, resize).
>
> Summary:
> The 1D Array<T> constructors are gone. Array<T> is always at least 2D,
> so the 1D constructors were confusing, and against the above stated
> politics. Further, the initialized 1D ctor was in conflict with a 2D
> ctor signature.
> You should no longer write
> Array<double> x (n);
> there are no 1D arrays, so don't do this. In fact it will still work,
> but give a deprecation warning (under GCC). Instead, specify
> explicitly either row or column vector:
> Array<double> x (1, n);
> Array<double> y (n, 1);
>
> Array<T> (octave_idx_type, T) won't work (it conflicts with the 2d ctor).
>
> Ditto for Array<T>::resize, Array<T>::clear. In this way, you can
> avoid the pitfalls where column vectors were unexpectedly changed to
> row vectors.
> Array <double> x(n); // x is column vector now
> x.resize (1).resize (n); // x is row vector now!!
>
> resize (n) will still work, but is deprecated. resize (n, T) won't work.
>
> Similarly, dim_vector (n) is deprecated. use (1, n) or (n, 1) explicitly.
> In those classes where the vector orientation is implied - RowVector,
> ColumnVector, string_vector, or octave_value_list, you can still use
> 1D constructors, i.e.
>
> ColumnVector c(3);
> ColumnVector c(3, 1.0);
>
> are still OK.
>
> The MArrayN and MArray2 classes are gone (ArrayN was removed
> previously). classes like Matrix or ColumnVector now derive directly
> from MArray.
> charMatrix and boolMatrix still derive from Array2, I'll fix that later.
>
> Comments? Suggestions?
>

Another change is upstream:
http://hg.savannah.gnu.org/hgweb/octave/rev/a3635bc1ea19

This gets rid of Array2 and rebases boolMatrix and charMatrix directly on Array.
For the time being, Array3 is retained as a convenience wrapper (for
instance, it has the 3d constructor
or Array3::index (idx_vector, idx_vector, idx_vector)).

enjoy

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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