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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5a57f33d0f284ad2,start X-Google-Attributes: gid103376,public From: Doug Rogers Subject: Problem instantiating "&" using GNAT Date: 1997/11/18 Message-ID: <64sh1i$9h9$1@news1.mnsinc.com>#1/1 X-Deja-AN: 290479352 Organization: Monumental Network Systems Newsgroups: comp.lang.ada Date: 1997-11-18T00:00:00+00:00 List-Id: This is a multi-part message in MIME format. --------------F9EF93051859A6F7328A4A7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I've looked at this code quite a bit and can't see what I'm doing wrong. I'm assuming that there's an error on my part and not on the compiler, since I've only encountered a few problems with GNAT, and they were all resolved many versions ago. I'm instantiating a generic matrix concatenation operation, called "&" of course. Here's what GNAT gives: gnatmake fun gcc -c fun.adb fun.adb:8:04: instantiation error at fun_matrix.adb:30 fun.adb:8:04: invalid operand types for operator "&" gnatmake: "fun.adb" compilation error The code is attached. Any help would be appreciated. Doug --_._-__-____------_--_-_-_-___-___-____-_--_-___--____-___--_-__--___-_ Doug Rogers, ICI | And a statute which either forbids or requires V:703.893.2007x220 | the doing of an act in terms so vague that men of F:703.893.5890 | common intelligence must necessarily guess at its ___________________| meaning and differ as to its application, violates the first essential of due process of law. [Connally v. General Construction, 269 USC 385 (1926)] --------------F9EF93051859A6F7328A4A7 Content-Type: text/plain; charset=us-ascii; name="all.adb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="all.adb" generic type Real is digits <>; -- private; type Index is range <>; type Vector is array (Index range <>) of Real; type Matrix is array (Index range <>, Index range <>) of Real; package Fun_Matrix is function Row (M : Matrix; I : Index) return Vector; procedure Set_Row (M : out Matrix; I : in Index; To : in Vector); -- -------------------------------------------------------------------- -- "&": -- Concatenates two matrices into upper left and lower right corners -- of the returned matrix. -- function "&" (M1, M2 : Matrix) return Matrix; end Fun_Matrix; package body Fun_Matrix is function Row (M : Matrix; I : Index) return Vector is V : Vector (M'range(2)); begin for J in V'range loop V(J) := M(I,J); end loop; return V; end Row; procedure Set_Row (M : out Matrix; I : in Index; To : in Vector) is begin for J in To'range loop M(I,M'first(2) + J - To'first) := To(J); end loop; end Set_Row; -- -------------------------------------------------------------------- -- "&": -- Concatenates two matrices into upper left and lower right corners -- of the returned matrix. -- function "&" (M1, M2 : Matrix) return Matrix is Result : Matrix (Index'first .. Index'first + M1'length(1) + M2'length(1) - 1, Index'first .. Index'first + M1'length(2) + M2'length(2) - 1); -- := (others => (others => 0.0)); Zero1 : constant Vector (M1'range(2)) := (others => 0.0); Zero2 : constant Vector (M2'range(2)) := (others => 0.0); begin for I in M1'range(1) loop Set_Row (Result, Result'first + I - M1'first(1), To => Row (M1, I) & Zero2); end loop; for I in M2'range(1) loop Set_Row (Result, Result'first + M1'length(1) + I - M2'first(1), To => Zero1 & Row (M2, I)); end loop; return Result; end "&"; end Fun_Matrix; with Fun_Matrix; procedure Fun is type Real is digits 15; type Vector is array (Positive range <>) of Real; type Matrix is array (Positive range <>, Positive range <>) of Real; package Math is new Fun_Matrix (Real, Positive, Vector, Matrix); use Math; begin null; end Fun; --------------F9EF93051859A6F7328A4A7--