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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada.Numerics.Long_Real_Arrays Date: Wed, 25 Jan 2017 16:17:01 +0000 Organization: A noiseless patient Spider Message-ID: References: <5a19787c-a11c-470e-8cef-2c5dc4897bf7@googlegroups.com> <40c85340-df43-43f7-8974-dca83704036e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b135cad8a1ac390d468bcfdc336a5210"; logging-data="11495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gYack30mdOdHvjB9Lsk6+d4iOEFApjVM=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin) Cancel-Lock: sha1:jiQoPuK7ZEYka3Ch53uMzq8qX2Q= sha1:o6NZh5kTAhxaeCXjPoj2tl6/y+Y= Xref: news.eternal-september.org comp.lang.ada:33162 Date: 2017-01-25T16:17:01+00:00 List-Id: hnptz@yahoo.de writes: > On Wednesday, January 25, 2017 at 1:25:18 PM UTC+1, hn...@yahoo.de wrote: >> Hi, >> >> these are my definitions: >> >> with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; >> package nm is >> >> Np : Positive; >> Type R_Vector is new Real_Vector (1..Np); >> Type R_Matrix is array (Positive range <>) of R_Vector; >> >> procedure nm1 (P : in out R_Matrix); >> >> end nm; > First, I want to keep the length of P open until I fix it in > test_nm.adb. The length of R_Vector is always Mp-1. Second, I want to > use the builtin Real_Vector arithmetic, that I do not have to resort > to loops. Using Real_Matrix definitions won't allow it, as slices of > n-dimensional arrays are not possible. You could try a generic? with Ada.Numerics.Long_Real_Arrays; generic Rows : Positive; package Nm_G is subtype R_Vector is Ada.Numerics.Long_Real_Arrays.Real_Vector (1 .. Rows - 1); type R_Matrix is array (1 .. Rows) of R_Vector; end Nm_G; with Ada.Text_Io; use Ada.Text_Io; with Nm_G; procedure Nm_Test is package Nm is new Nm_G (Rows => 3); use Nm; P : R_Matrix := ((42.0, 42.0), (43.0, 43.0), (44.0, 44.0)); V : R_Vector := P (P'Last); begin Put_Line ("v: " & V (V'First)'Img & ", " & V (V'Last)'Img); end Nm_Test;