From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.36.79 with SMTP id k76mr6686853iok.32.1511643538362; Sat, 25 Nov 2017 12:58:58 -0800 (PST) X-Received: by 10.157.1.175 with SMTP id e44mr1406981ote.1.1511643538285; Sat, 25 Nov 2017 12:58:58 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.mixmin.net!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!i6no6271688itb.0!news-out.google.com!193ni2441iti.0!nntp.google.com!i6no6271684itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 25 Nov 2017 12:58:57 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.209.130.105; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 71.209.130.105 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <370d6fa0-568a-4a97-9189-7839c91cbe7c@googlegroups.com> Subject: Re: How to access an array using two different indexing schemes From: Jerry Injection-Date: Sat, 25 Nov 2017 20:58:58 +0000 Content-Type: text/plain; charset="UTF-8" Xref: feeder.eternal-september.org comp.lang.ada:49148 Date: 2017-11-25T12:58:57-08:00 List-Id: 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