comp.lang.ada
 help / color / mirror / Atom feed
From: "Jerry" <lanceboyle@qwest.net>
Subject: How to use Annex G.3 Vectors and Matrices in bindings to C arrays
Date: 11 Nov 2006 19:45:35 -0800
Date: 2006-11-11T19:45:35-08:00	[thread overview]
Message-ID: <1163303134.998680.268570@h54g2000cwb.googlegroups.com> (raw)

A while back, I wrote a binding for a C program (PLplot) in which I
have a declaration thus:

    type Long_Float_Array_1D is array (Integer range <>) of aliased
Long_Float;

and similarly for a 2D array. As I understand it (I'm a little unclear
about this even though I did most of the work myself, help from this
list notwithstanding), the aliasing of the array components was
required in order to cause the pass-by-reference to the C code to work
correctly.

Now, I am working with the Annex G.3.1 and G.3.2 features which are new
to Ada 2005, "Vector and Matrix Manipulation." I have those features
working correctly on their own; however, it only makes sense to
rationalize all 1D and 2D numerical arrays against the Annex G.3
features. Thus, I am looking into getting my PLplot binding to work
with arrays which are (sub)typed from the Annex G.3 declarations. For
example, here is the declaration from the spec of
Ada.Numerics.Generic_Real_Arrays which is GNAT file a-ngrear.ads:

       type Real_Vector is array (Integer range <>) of Real'Base;

(The Long_Float version, for example, is an instantiation of this
generic and is named Ada.Numerics.Long_Real_Arrays.)

So--how do I get objects and subtypes based on the type Real_Vector to
have aliased components or, how do I get a type that is type-compatible
with Real_Vector but which has aliased components?

I wonder if I am incorrect in believing that the binding to C-arrays
need aliased components. Like I said, the reason for that is a little
fuzzy to me right now. But I do know that if I remove the aliased
component requirement from Long_Float_Array_1D the binding will not
compile.

I also wonder if it is generally possible to rationalize other bindings
which involve connecting to C arrays by using (sub)types of the Annex
G.3 vector and matrix types. If not, that would seem to make the Annex
G.3 features useless whenever C array bindings are needed.

I next want to look into binding to the GNU Scientific Library (GS) and
hope to be able to derive all the 1D and 2D arrays from those specified
in Annex G.3.

Thanks as always,
Jerry




             reply	other threads:[~2006-11-12  3:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-12  3:45 Jerry [this message]
2006-11-12  8:45 ` How to use Annex G.3 Vectors and Matrices in bindings to C arrays Yves Bailly
2006-11-13 10:48   ` Jerry
2006-11-12 19:39 ` Jeffrey R. Carter
2006-11-13  7:09   ` tmoran
2006-11-13 11:20   ` Jerry
2006-11-13 17:42     ` Yves Bailly
2006-11-13 19:50       ` Gautier
2006-11-14  5:28         ` Jerry
2006-11-14  5:18       ` Jerry
2006-11-13 19:09     ` Jeffrey R. Carter
2006-11-14  7:31       ` Jerry
2006-11-14  7:54       ` Jerry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox