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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.cs.hut.fi!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Robin" Newsgroups: comp.lang.ada Subject: Re: How to access an array using two different indexing schemes Date: Sun, 26 Nov 2017 21:22:28 +1100 Organization: Aioe.org NNTP Server Message-ID: References: <370d6fa0-568a-4a97-9189-7839c91cbe7c@googlegroups.com> Reply-To: "Robin" NNTP-Posting-Host: zgURL8BkmJu8LEkj1uTL5Q.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org X-Antivirus: Avast (VPS 171125-0, 25/11/2017), Outbound message X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Antivirus-Status: Clean X-Notice: Filtered by postfilter v. 0.8.2 Xref: feeder.eternal-september.org comp.lang.ada:49160 Date: 2017-11-26T21:22:28+11:00 List-Id: "Jerry" wrote in message news:370d6fa0-568a-4a97-9189-7839c91cbe7c@googlegroups.com... > 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. I cited an instance where elements of an array can be accessed with different indexes. It is more complex than the one that you illustrated, but it is still an instance of the same thing. Your example is trivially handled with the iSUB facility. > You describe a situation where the data are actually different (deleting rows and columns). It is not "deleting" rows and columns; it omits them, using different indices for the same elements. Even so, bounds checking is available for all uses. > Your problem could be handled by array slicing for nD arrays where n > 1. No need for slicing. > 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 --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus