From: Simon Wright <simon@pushface.org>
Subject: Re: Ada.Numerics.Long_Real_Arrays
Date: Thu, 26 Jan 2017 14:52:56 +0000
Date: 2017-01-26T14:52:56+00:00 [thread overview]
Message-ID: <lypoj9vpo7.fsf@pushface.org> (raw)
In-Reply-To: 712de11c-94ae-4703-8cfb-9ff2decccaeb@googlegroups.com
This will compile, and preserve visibility of the underlying Vectors.
I'm not sure whether one could get something less clumsy by using
Ada.Containers.Indefinite_Vectors to hold the R_Vectors.
with Ada.Numerics.Long_Real_Arrays;
generic
Np : Positive;
package Nm_G is
subtype R_Vector
is Ada.Numerics.Long_Real_Arrays.Real_Vector (1 .. Np);
type R_Matrix is array (1 .. Np + 1) of R_Vector;
end Nm_G;
with Nm_G;
package Nm is
-- I assume there's more than just Fnm here; if not, Fnm could be a
-- library-level generic subprogram.
--
-- Of course, if there _is_ more than just Fnm, it's likely the
-- other components will also need to know which instantiation of
-- Nm_G they have to deal with, and the 'with package' bit would
-- need to be placed on the Nm (which itself has to be generic).
generic
-- This generic needs to know which instantiation of Nm_G it is
-- to deal with.
with package Nm_I is new Nm_G (<>);
-- Now we know what type the parameter of the actual F has to
-- be.
with function F (R : Nm_I.R_Vector) return Long_Float;
procedure Fnm (P : in out Nm_I.R_Matrix);
end Nm;
package body Nm is
procedure Fnm (P : in out Nm_I.R_Matrix) is
begin
null;
end Fnm;
end Nm;
with Nm;
with Nm_G;
procedure Test_Nm is
package Nm_Inst is new Nm_G (Np => 2);
function Actual_F (R : Nm_Inst.R_Vector) return Long_Float is (42.0);
procedure Actual_Fnm is new Nm.Fnm (Nm_I => Nm_Inst,
F => Actual_F);
P : Nm_Inst.R_Matrix := ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0));
begin
Actual_Fnm (P);
end Test_Nm;
next prev parent reply other threads:[~2017-01-26 14:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 12:25 Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 13:50 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-25 14:11 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 16:17 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-25 18:35 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 21:29 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-26 7:47 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26 11:54 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-26 14:52 ` Simon Wright [this message]
2017-01-26 15:03 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26 7:49 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26 7:55 ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-27 16:51 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-27 18:39 ` Ada.Numerics.Long_Real_Arrays 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