FYI: ArrayN gone

View: New views
2 Messages — Rating Filter:   Alert me  

FYI: ArrayN gone

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

as a step towards simplifying the liboctave array class hierarchy, I
removed the ArrayN template class:
http://hg.savannah.gnu.org/hgweb/octave/rev/b4fdfee405b5

Rationale:
I don't know the historical purpose of ArrayN, but it surely evolved
into being a mere thin wrapper over Array, adding no useful
functionality besides defining a stream output operator, which can be
easily absorbed into Array.cc (and I'm not sure it's used at all).
Since Array is already multi-dimensional, I think the existence of
ArrayN only added confusion - it certainly confused me when I became a
contributor.
Further, it implied occassional necessity for ugly typecasts - for
instance, Array<T> usually needed to be re-cast to ArrayN<T> in order
to be stored in octave_value.
So I removed the ArrayN layer and replaced its usage by Array
everywhere. This went surprisingly flawlessly; still it uncovered some
hidden bugs in operator handlers where implicit conversion
constructors were silently doing unexpected things, and also some
mismatching types being passed around. Hence the seemingly unrelated
changes.

the ArrayN.h include file still exists but only includes Array.h and
#defines ArrayN to Array. Therefore, a lot of existing code
referencing ArrayN will just silently work with Array instead.
However, I also added a warning for GNU-compatible compilers (this can
be debated), so that users become aware of the obsolete feature. This
layout of things may be debated; for instance, we may make ArrayN
forever a valid alias for Array and print no warning...

MArrayN is the next target (to be merged with MArray). I'm not yet
sure what to do with the Array2 classes.

comments?

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

FYI: ArrayN gone

by John W. Eaton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 16-Oct-2009, Jaroslav Hajek wrote:

| as a step towards simplifying the liboctave array class hierarchy, I
| removed the ArrayN template class:
| http://hg.savannah.gnu.org/hgweb/octave/rev/b4fdfee405b5
|
| Rationale:
| I don't know the historical purpose of ArrayN, but it surely evolved
| into being a mere thin wrapper over Array, adding no useful

I think the original classes had Array as a single-dimensional array
only, Array2 as a 2-dimensional array, and ArrayN providing
N-dimensional arrays.  But then at some point, Array was extended to
handle all dimensions.  So I think it is good to get rid of ArrayN.
Thanks for doing this job.

| MArrayN is the next target (to be merged with MArray).

OK.

| I'm not yet sure what to do with the Array2 classes.

I suppose the funtionality of Array2 might be absorbed by Array.  For
things that only make sense for 2-d arrays (transpose, hermitian,
etc.) we would simply need checks to ensure that the object actually
has exactly 2 dimensions and otherwise throw an error.  Would that work?

jwe