From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to access an array using two different indexing schemes
Date: Wed, 29 Nov 2017 08:03:02 -0800 (PST)
Date: 2017-11-29T08:03:02-08:00 [thread overview]
Message-ID: <0b6bd27e-e9ec-4854-bbb1-85e1d9ac92e1@googlegroups.com> (raw)
In-Reply-To: <ac428886-d567-4692-b8b7-22fcb69a755f@googlegroups.com>
On Tuesday, November 28, 2017 at 9:57:48 PM UTC-7, Jerry wrote:
>
> Your method shows how to pass the re-dimensioned array to a subprogram for processing with a typecast. But I also need to process the array in the same program that the subtype is declared. How would I do the typecast without allocating more memory?
>
> Something like this:
>
> procedure Doubly_Indexed_Array is
> declare x with dimensions (0 .. 4)
> declare y with dimensions (1 .. 5) using the same memory as x but
> accessed with different indices
> begin
> x(0) := 10.0;
> y(3) := 20.0;
> print x(0) resulting in 10.0
> print y(1) resulting in 10.0
> print x(2) resulting in 20.0
> print y(3) resulting in 20.0
> end Doubly_Indexed_Array;
Subtype Real is Float range Float'Range; -- Get rid of non-numeric.
Type General_Real_Array is Array(Integer range <>) of Real;
Procedure Do_Stuffs( Data : in out General_Real_Array ) is
Subtype Indexing is General_Real_Array(1..Data'Length);
Subtype Offset is General_Real_Array(0..Integer'Pred(Data'Length));
Indexed : Indexing renames Data;
Offseted : Offset renames Data;
Begin
-- Stuffs!
null;
End Do_Stuffs;
next prev parent reply other threads:[~2017-11-29 16:03 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
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 [this message]
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