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.36.44.134 with SMTP id i128mr8546659iti.14.1511523727063; Fri, 24 Nov 2017 03:42:07 -0800 (PST) X-Received: by 10.157.94.7 with SMTP id d7mr1187526oti.8.1511523726967; Fri, 24 Nov 2017 03:42:06 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!i6no5246818itb.0!news-out.google.com!193ni554iti.0!nntp.google.com!i6no5246815itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 24 Nov 2017 03:42:06 -0800 (PST) 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 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: How to access an array using two different indexing schemes From: Jerry Injection-Date: Fri, 24 Nov 2017 11:42:07 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 2093085057 X-Received-Bytes: 2602 Xref: feeder.eternal-september.org comp.lang.ada:49128 Date: 2017-11-24T03:42:06-08:00 List-Id: I want to access an array such as Real_Vector (built-in for Ada >=3D 2005) = with two different indexing schemes. For example, I would access a Real_Vec= tor indexed (0 .. 4) when thinking of it as a times series and the same dat= a indexed (1 .. 5) when thinking of it as a vector. Another application wou= ld be a vector indexed (-128 .. 127) because it fits my problem domain, per= haps a spatial variable, but I need to index it as (0 .. 255) when thinking= of doing a Fast Fourier Transform on it. I could declare two arrays such as x : Real_Vector(0 .. 4); y : Real_Vector(1 .. 5);=20 Ada then allows the assignments y :=3D x; and x :=3D y; but this has two problems. First, I have wasted memory and cycles by declar= ing y and copying x into it. Second, I would then have a kind of version co= ntrol problem where every time I modified one, I have to copy it to the oth= er. I have the notion that I should be able to accomplish this using pointers b= ut I can=E2=80=99t seem to crack how do to this. I=E2=80=99ve tried all sor= ts of things and am resigned to doing the above duplication if I have to. (= My arrays can be _much_ larger so the overhead might be significant. They m= ight also be two-dimensional, as in Real_Matrix or Complex_Matrix.) I'm currently looking at System.Address_To_Access_Conversions but I thought= I would query the list in the meantime. Any ideas? Thanks, Jerry