From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: How to initialize a matrix of one column only?
Date: Sat, 07 Jul 2012 21:47:09 -0400
Date: 2012-07-07T21:47:09-04:00 [thread overview]
Message-ID: <nospam-E0F1CA.21470907072012@news.aioe.org> (raw)
In-Reply-To: jtaj2c$18k$1@speranza.aioe.org
In article <jtaj2c$18k$1@speranza.aioe.org>,
"Nasser M. Abbasi" <nma@12000.org> wrote:
[...]
> Here is the code, I write
>
> ----------------------
> with Interfaces.Fortran;
> use Interfaces.Fortran;
> with lbase;
> ....
> N: Fortran_Integer := 3;
> B: labase.Fortran_Real_Matrix ( 1..N, 1..1 );
> BEGIN
> B := ((9.0) , -- here is the problem
> (2.0) ,
> (-2.0));
> ....
> --------------------------------------------
>
> where the labase package simply introduces a type for
> Fortran_Real_Matrix as follows
>
> ----------------------------
> type Fortran_Real_Matrix is array (Fortran_Integer range <>,
> Fortran_Integer range <>)
> of Real;
> pragma Convention (Fortran, Fortran_Real_Matrix);
> --------------------
>
>
> >gnatmake -I../ada lap42.adb
> gcc -c -I../ada lap42.adb
> lap42.adb:35:16: nested array aggregate expected
> lap42.adb:35:16: if single-component aggregate is intended, write e.g. (1 =>
> ...)
> gnatmake: "lap42.adb" compilation error
> >
>
> I tried B:=(1=>9.0,2=>2.03=>-2.0);
> and B := ((9.0 ,2.0 , 3));
> but non working.
>
> What is the correct syntax to use?
According to 4.3.3 Array Aggregates, you need to use named notation for
a single component, otherwise "a single expression in parentheses is
interpreted as a parenthesized expression."
B := ((1 => 9.0),
(1 => 2.0),
(1 => -2.0));
<http://www.ada-auth.org/standards/12rm/html/RM-4-3-3.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
next prev parent reply other threads:[~2012-07-08 1:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-08 0:08 How to initialize a matrix of one column only? Nasser M. Abbasi
2012-07-08 0:20 ` Nasser M. Abbasi
2012-07-08 1:47 ` John B. Matthews [this message]
2012-07-08 2:09 ` Nasser M. Abbasi
2012-07-08 17:05 ` Brian Drummond
2012-07-13 15:19 ` Robert A Duff
2012-07-13 16:11 ` gautier_niouzes
2012-07-08 7:27 ` Simon Wright
2012-07-08 7:43 ` Stephen Leake
2012-07-08 22:56 ` Jerry
2012-07-09 9:35 ` Simon Wright
2012-07-12 4:13 ` Jerry
2012-07-12 8:50 ` Simon Wright
2012-07-13 23:15 ` Jerry
2012-07-14 9:46 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox