comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <list_email@icloud.com>
Subject: Re: How to access an array using two different indexing schemes
Date: Sat, 25 Nov 2017 12:58:57 -0800 (PST)
Date: 2017-11-25T12:58:57-08:00	[thread overview]
Message-ID: <370d6fa0-568a-4a97-9189-7839c91cbe7c@googlegroups.com> (raw)
In-Reply-To: <ovc2ni$lfb$1@gioia.aioe.org>

On Saturday, November 25, 2017 at 8:37:25 AM UTC-7, Robin wrote:
> "Jeffrey R. Carter"  wrote in message 
> ...
> > On 11/24/2017 12:42 PM, Jerry wrote:
> >> I want to access an array such as Real_Vector (built-in for Ada >= 2005) with two different 
> >> indexing schemes. For example, I would access a Real_Vector indexed (0 .. 4) when thinking of it 
> >> as a times series and the same data indexed (1 .. 5) when thinking of it as a vector. Another 
> >> application would be a vector indexed (-128 .. 127) because it fits my problem domain, perhaps a 
> >> spatial variable, but I need to index it as (0 .. 255) when thinking of doing a Fast Fourier 
> >> Transform on it.
> >
> > I can't think of any situation when I'd need to access the same component of an array using 
> > different indices,
> 
> It can arise in boundary value problems, where operations are carried out
> on all elements of a matrix except the first and last rows, and first and
> last columns.
> 
> In PL/I, such situations are handled using the iSUB facility. 
> 
If I understand correctly, this is actually different from what I described, which is accessing the same data with different indexing schemes.

You describe a situation where the data are actually different (deleting rows and columns). Your problem could be handled by array slicing for nD arrays where n > 1.

As has been discussed here before, Ada strangely and annoyingly lacks slicing for multidimensional arrays, leading the programmer to devise ugly error-prone ad hoc methods, and that is very un-Ada-like.

Your problem would also be solved by a sub-matrix capability which is apparently what you describe for PL/1. Of course Ada also lacks this capability along with matrix compositions, both of which Matlab excels at.

These missing array features and the fairly trivial but readability-reducing method of using () for array indexing instead of the highly suggestive [] are probably the main things that keep Ada from being a first-class language for numerical work.

It seems that if some of these concerns were addressed it would help Ada expand its fields of use, a desire which has been expressed in the past.

Jerry


  reply	other threads:[~2017-11-25 20:58 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 11:42 How to access an array using two different indexing schemes Jerry
2017-11-24 12:33 ` Jeffrey R. Carter
2017-11-24 15:52   ` AdaMagica
2017-11-24 22:25     ` Jerry
2017-11-25 13:57       ` AdaMagica
2017-11-24 22:23   ` Jerry
2017-11-25 15:39   ` Robin
2017-11-25 20:58     ` Jerry [this message]
2017-11-26 10:22       ` Robin
2017-11-28 21:57       ` G. B.
2017-11-24 17:37 ` A. Cervetti
2017-11-24 21:48   ` Jerry
2017-11-24 22:15     ` Robert A Duff
2017-11-24 23:38       ` Jerry
2017-11-26  1:07         ` Jerry
2017-11-26  8:58           ` Dmitry A. Kazakov
2017-11-26 10:31             ` Jerry
2017-11-28  1:31             ` Randy Brukardt
2017-11-28  1:25   ` Randy Brukardt
2017-11-29  4:57     ` Jerry
2017-11-29 15:01       ` AdaMagica
2017-11-29 15:21         ` AdaMagica
2017-11-30  5:32           ` Jerry
2017-11-30  5:30         ` Jerry
2017-11-29 15:03       ` AdaMagica
2017-11-29 20:53         ` Randy Brukardt
2017-11-29 16:03       ` Shark8
2017-11-29 17:04         ` AdaMagica
2017-11-29 20:56           ` Randy Brukardt
2017-11-30  5:56             ` Jerry
2017-11-30 11:11               ` AdaMagica
2017-11-30 11:40                 ` AdaMagica
2017-11-30 14:47                   ` Niklas Holsti
2017-11-30 17:30                     ` AdaMagica
2017-11-30 19:31                       ` G. B.
2017-11-30 19:43                         ` Shark8
2017-11-30 22:10                           ` Randy Brukardt
2017-11-30 21:57                     ` Randy Brukardt
2017-11-30 22:49                 ` Jerry
2017-11-30 23:00                   ` Jerry
2017-11-30 21:50               ` Randy Brukardt
2017-11-30 23:13                 ` Jerry
2017-11-24 18:37 ` Per Sandberg
2017-11-24 21:28   ` Jerry
2017-11-24 21:40     ` Dmitry A. Kazakov
2017-11-28  1:33     ` Randy Brukardt
2017-11-24 22:12 ` Robert A Duff
2017-11-28  1:39   ` Randy Brukardt
replies disabled

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