From: Lucretia <laguest9000@googlemail.com>
Subject: Re: REQ: Extend slices for n dimensional arrays for Ada 202X
Date: Fri, 27 Jan 2017 06:04:51 -0800 (PST)
Date: 2017-01-27T06:04:51-08:00 [thread overview]
Message-ID: <baad1198-69e0-46c2-bbe7-21a148e076de@googlegroups.com> (raw)
In-Reply-To: <o6d2eh$4mu$1@gioia.aioe.org>
On Thursday, 26 January 2017 14:52:04 UTC, Dmitry A. Kazakov wrote:
> On 26/01/2017 15:01, Lucretia wrote:
> > On Thursday, 26 January 2017 13:29:47 UTC, Lucretia wrote:
> >
> >>
> >> Texture (x1 .. x2, y1 .. y2) := Buffer; -- Buffer is the correct size.
> >
> > I forgot to mention something else. I put the above notation down as
> > someone in #Ada liked tha, but I would prefer the following:
> >
> > Texture (x1, y1 .. x2, y2) := Buffer; -- Buffer is the correct size.
>
> I don't understand the latter. (X1, Y1) .. (X2, Y2) is not a submatrix
> it is a linear slice:
You're being deliberately obtuse. I even spelt out the semantics above. The language designers spell out the semantics of the language constructs as I did.
For the 1D case, we define an array as:
type Some_Array is array (Positive range 1 .. 5) of Integer;
Access an element with:
T : Some_Array;
T (4) := 3;
Slice with:
S : Some_Array := T (2 .. 4);
For the 2D and above case, we define an array as:
type Some_Array is array (Positive range 1 .. 5, Positive range 1 .. 10) of Integer;
Access an element with:
T : Some_Array;
T (1, 1) := 3;
So we could slice with:
S : Some_Array := T (2, 2 .. 4, 6); -- Square slice!
So in the following case (row-major order):
| 1 2 3 4
-----------
1 | a e i m
2 | b f j n
3 | c g k o
4 | d h l p
A slice of (2,2 .. 3,4) would give:
| 1 2
-------
1 | f j
2 | g k
3 | h l
Not a linear vector, because that's not the semantics I'm looking for, is it?
>
> You forgot notation for whole index range:
>
> I (<>, 1) -- column 1.
This is irrelevant as you cannot assign I (<>) in the 1D case anyway.
Luke.
next prev parent reply other threads:[~2017-01-27 14:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 13:29 REQ: Extend slices for n dimensional arrays for Ada 202X Lucretia
2017-01-26 14:01 ` Lucretia
2017-01-26 14:03 ` Lucretia
2017-01-26 14:52 ` Dmitry A. Kazakov
2017-01-27 9:19 ` Alejandro R. Mosteo
2017-01-27 14:04 ` Lucretia [this message]
2017-01-26 18:29 ` Randy Brukardt
2017-01-27 1:54 ` Robert Eachus
2017-01-27 5:39 ` Robert Eachus
2017-01-27 14:06 ` Lucretia
2017-01-27 23:30 ` Randy Brukardt
2017-01-28 0:58 ` Robert Eachus
2017-01-27 9:34 ` Dmitry A. Kazakov
2017-01-27 13:53 ` G.B.
2017-01-27 14:20 ` Dmitry A. Kazakov
2017-01-27 23:37 ` Randy Brukardt
2017-01-28 9:08 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox