From: bdbryant@mail.utexas.edu (Bobby D. Bryant)
Subject: Re: Dynamic array allocation and STL equivalents?
Date: Sat, 12 Feb 2005 06:19:30 +0000 (UTC)
Date: 2005-02-12T06:19:30+00:00 [thread overview]
Message-ID: <cuk75h$878$1@geraldo.cc.utexas.edu> (raw)
In-Reply-To: 1108127216.221977.60830@o13g2000cwo.googlegroups.com
On Fri, 11 Feb 2005, brian.b.mcguinness@lmco.com wrote:
> One interesting project would be to create an object class hierarchy to
> implement APL arrays. In APL, the lengths of an array's dimensions can
> change, e.g. by concatenating new rows or columns onto a matrix, or
> concatenating two matrices, and the number of dimensions can also
> change, e.g. by "laminating" two 12x30 arrays to form a 2x12x30 array.
> In C++, an obvious solution would be to use STL vectors, e.g.:
>
> class RealArray {
> private:
> vector <unsigned long> dimensions;
> vector <double> data;
> public:
> // define an indexing operator[] to use the dimensions
> // vector to translate sets of indices into offsets
> // into the data array
> ...
> };
>
> But I don't know how to do this in Ada.
If you can work out the recursive data typing issues, you might be
able to do it by overloading the '&' catenation operator to bind a new
row/column/layer onto an array or matrix.
The indexing would be tricky, but if you want think of an array access
as a sort of function call (send an argument, get a result), you might
be able to kludge together a function to do the work. Let the
function's first argument be the data structure, and the second a
pointer to an (unconstrained) array type that holds the (variable
length) value of the indices of interest.
I think the concept is sound, if you can get everything past the type
checking, though specifying the indices in a program might be tedious.
--
Bobby Bryant
Austin, Texas
prev parent reply other threads:[~2005-02-12 6:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-11 13:06 Dynamic array allocation and STL equivalents? brian.b.mcguinness
2005-02-11 13:43 ` Jeff C
2005-02-14 15:23 ` Marc A. Criley
2005-02-11 14:41 ` Dmitry A. Kazakov
2005-02-11 15:50 ` Adrien Plisson
2005-02-11 17:47 ` REH
2005-02-12 9:28 ` Dmitry A. Kazakov
2005-02-12 18:52 ` Robert A Duff
2005-02-11 17:24 ` Bobby D. Bryant
2005-02-12 0:06 ` Robert A Duff
2005-02-12 3:45 ` Bobby D. Bryant
2005-02-11 18:07 ` Matthew Heaney
2005-02-11 18:36 ` Martin Krischik
2005-02-11 19:35 ` brian.b.mcguinness
2005-02-12 1:04 ` Jeffrey Carter
2005-02-12 6:19 ` Bobby D. Bryant [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox