comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: how to print an array range?
Date: Wed, 27 Jun 2012 00:17:13 +0200
Date: 2012-06-27T00:17:13+02:00	[thread overview]
Message-ID: <jp27uwpu8y7k$.1cknadni65094$.dlg@40tude.net> (raw)
In-Reply-To: wccvcidwyj0.fsf@shell01.TheWorld.com

On Tue, 26 Jun 2012 17:31:31 -0400, Robert A Duff wrote:

> Why didn't they make the index subtype Positive (or
> maybe Natural) instead of Integer?

Why should they limit index to a subset which would have more problems with
not being closed upon arithmetic operations than Integer? The only real
constraint here is the array bounds. Ideally index should be
Universal_Integer.

> Is it important to allow negative index values?

Yes, there were several cases I used a negative lower bound.

One important case is when you have a n-elements thick border around the
original matrix filled with some special values, usually zeros. This
technique is used when matrix elements are convoluted. E.g. let you compute
something like diagonal sums like:

   A(I - 2, J) + A(I - 1, J) + A (I, J) + A (I + 1, J) + A (I + 2, J)

You don't want to check I for special border cases A'First (1), A'First (1)
+ 1, A'Last (1) - 1, A'Last (1). Instead of that you add a border of zeros,
trading a little space for index checks, and get more uniform and efficient
code.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2012-06-26 22:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 13:47 how to print an array range? Nasser M. Abbasi
2012-06-26 13:54 ` Georg Bauhaus
2012-06-26 14:08   ` Nasser M. Abbasi
2012-06-26 14:24     ` Nasser M. Abbasi
2012-06-26 15:07       ` AdaMagica
2012-06-26 15:53       ` Georg Bauhaus
2012-06-26 16:28         ` Nasser M. Abbasi
2012-06-26 16:58           ` Georg Bauhaus
2012-06-26 17:05           ` John B. Matthews
2012-06-26 17:13             ` Georg Bauhaus
2012-06-26 19:28               ` John B. Matthews
2012-06-26 17:15           ` Adam Beneschan
2012-06-26 21:31     ` Robert A Duff
2012-06-26 22:17       ` Dmitry A. Kazakov [this message]
2012-06-26 22:39       ` Randy Brukardt
     [not found]       ` <33dku79r14uuvmlgpodg9ri7prnq9v5f94@invalid.netcom.com>
2012-06-26 23:13         ` Jeffrey Carter
2012-06-27  6:58           ` Jacob Sparre Andersen
2012-06-26 14:07 ` Dmitry A. Kazakov
2012-06-28  6:59 ` Shark8
replies disabled

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