comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix?
Date: Thu, 5 Jul 2012 11:56:38 -0700 (PDT)
Date: 2012-07-05T11:56:38-07:00	[thread overview]
Message-ID: <9b4da1cf-ca48-4b0b-97e5-012bf786a3e0@googlegroups.com> (raw)
In-Reply-To: <jt2qth$v2i$1@munin.nbi.dk>

On Wednesday, July 4, 2012 6:33:32 PM UTC-7, Randy Brukardt wrote:

> > Again, compared to what?
> 
> Compared to a language without 2-d slices.
> 
> This is distributed overhead, which programs would  have to pay whether or 
> not they used any 2-d slices. It would make all array parameters more 
> expensive. Distributed overhead is only acceptable in cases where there is a 
> clear and important value to the new feature.

It seems to me that the "generalized indexing" syntax of Ada 2012 could be used to write a package to support this functionality.  I think you could write a generic package that defines a 2-D array of an element type, but defines it as a tagged record that (internally) points to the array storage.  The package would define First, Last, Length functions for the type that take a dimension parameter.  It could also define a Slice function that would return a new 2-D array with the new bounds, but pointing to the same storage.  The new syntax would allow programmers to index the array in the same way they would now.  Of course, not all the syntax would be equivalent, and some would require extra typing; you'd have to say something like

   for I in Arr.First(1) .. Arr.Last(1) loop

instead of

   for I in Arr'Range(1)

I haven't studied all the details.  But off the top of my head, I think this could be made to work, and probably could be implemented with only a slight amount of overhead compared to if it were built into the language.  Since 2-D slices aren't a feature I'd expect to be used widely, this seems like a better approach than adding it to the language and incurring distributed overhead (on top of all the other overhead required to change all existing Ada implementations without breaking them, and making changes to the standard).

                          -- Adam



      parent reply	other threads:[~2012-07-05 18:56 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-24  8:05 Any easy/build-in construct to extract submatrices from larger matrix? Nasser M. Abbasi
2012-06-24  8:24 ` Dmitry A. Kazakov
2012-06-24  8:55   ` Nasser M. Abbasi
2012-06-24 11:10     ` Dmitry A. Kazakov
2012-06-24 12:16       ` Nasser M. Abbasi
2012-06-24 16:11         ` Dmitry A. Kazakov
2012-06-24 17:14           ` Nasser M. Abbasi
2012-06-24 18:33             ` Dmitry A. Kazakov
2012-06-25  5:44             ` J-P. Rosen
2012-06-25  6:32               ` Nasser M. Abbasi
2012-06-25  7:54                 ` J-P. Rosen
2012-06-25  8:20                   ` Dmitry A. Kazakov
2012-06-25 14:21                   ` Nasser M. Abbasi
2012-06-25  8:36                 ` Georg Bauhaus
2012-06-25 13:17                   ` Nasser M. Abbasi
2012-06-26 11:44                     ` Georg Bauhaus
2012-06-25 16:49                 ` Pascal Obry
2012-06-25 17:36                   ` Nasser M. Abbasi
2012-06-25 18:49                     ` stefan-lucks
2012-06-26  4:41                       ` Nasser M. Abbasi
2012-06-26  7:15                 ` Jacob Sparre Andersen
2012-06-26  9:51                   ` Nasser M. Abbasi
2012-06-25  9:33               ` Simon Wright
2012-06-26  2:48 ` Jerry
2012-06-26  4:19   ` Nasser M. Abbasi
2012-06-26  7:06   ` Nasser M. Abbasi
2012-06-26 12:54     ` Robert A Duff
2012-06-26 15:19       ` Adam Beneschan
2012-06-26 21:14         ` Robert A Duff
2012-06-27 23:42     ` Shark8
2012-06-26  7:10   ` Dmitry A. Kazakov
2012-06-26 15:06   ` Adam Beneschan
2012-06-26 21:19     ` Robert A Duff
2012-06-26 21:40       ` Adam Beneschan
2012-07-03  4:22         ` Randy Brukardt
2012-07-03  8:37           ` Dmitry A. Kazakov
2012-07-05  1:33             ` Randy Brukardt
2012-07-05  7:08               ` Dmitry A. Kazakov
2012-07-06 23:47                 ` Randy Brukardt
2012-07-07  8:22                   ` Dmitry A. Kazakov
2012-07-05 18:56               ` Adam Beneschan [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