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: Tue, 26 Jun 2012 08:06:21 -0700 (PDT)
Date: 2012-06-26T08:06:21-07:00	[thread overview]
Message-ID: <bbe2ffe2-d74d-4492-a950-6264ed96502c@googlegroups.com> (raw)
In-Reply-To: <788af57d-750d-418d-94bb-75c6557e36a9@g4g2000pbn.googlegroups.com>

On Monday, June 25, 2012 7:48:48 PM UTC-7, Jerry wrote:
> Most submatrix needs, including Nasser's example, can be handled by
> slices (or slice syntax--not sure what the difference is). Boolean
> masks would not often be needed.
> 
> Why doesn't Ada provide this? It seems that one of the Ada design
> principles has been to build in commonly used features rather than
> force the user to write them, setting up the greater possibility of
> mistakes and inefficiencies. Slices exist for 1D arrays; why not for
> >1D arrays?

I think one of the main reasons is that you couldn't do everything with a 2-D slice that you could do with a 1-D slice.  In particular, parameter passing would be an issue.  If you declare a procedure

  type Some_Array is array (natural range <>) of Something; 
  procedure Proc (A : in out Some_Array);

you can pass a slice of some other array

  Proc (B (7 .. 23));

and the since the elements of the slice are all still contiguous, Proc could treat the parameter the same as it would any other array--it wouldn't have to know whether the actual parameter was an entire array or a slice.  That wouldn't be the case with 2-D slices.  Some additional logic in Proc would be needed to deal with non-contiguous slices, and that additional logic would have to be there in Proc whether or not a 2-D slice was actually passed to it anywhere.

I realize that this may not be important to all programmers, and that they'd rather have the ability to express what they want and not worry about whether it slows things down ("distributed overhead").  But I think that being able to generate efficient code was one of the design principles in Ada 83.

                               -- Adam



  parent reply	other threads:[~2012-06-26 15:06 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 [this message]
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
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox