comp.lang.ada
 help / color / mirror / Atom feed
From: kst@king.cts.com (Keith Thompson)
Subject: Re: Maths LIb
Date: 1997/10/18
Date: 1997-10-18T00:00:00+00:00	[thread overview]
Message-ID: <877210437.50807@wagasa.cts.com> (raw)
In-Reply-To: x7vlnzrdr7i.fsf@pogner.demon.co.uk


Simon Wright (simon@pogner.demon.co.uk) wrote:
> "DRD Woodward" <doig@mwangi.demon.co.uk> writes:
> 
> > I'm using ... AvtivAda ... and having severe problems.
[...]
> > It tells me that the package I require, (GENERIC_ELEMENTARY_FUNCTIONS),
> >  is already compiled,and all I need do is use the a global  'With' clause,
> > then Instantiate it.
[..]
> It's called Ada.Numerics.Generic_Elementary_Functions -- see example:
> 
> with Ada.Text_Io;
> with Ada.Float_Text_Io;
> with Ada.Numerics.Generic_Elementary_Functions;
> procedure Math is
>   package Funcs is new Ada.Numerics.Generic_Elementary_Functions (Float);
>   X : Float := 0.5;
>   Y : Float;
> begin
>   Y := Funcs.Tanh (X);
>   Ada.Text_Io.Put ("tanh(0.5) is");
>   Ada.Float_Text_Io.Put (Y);
>   Ada.Text_Io.New_Line;
> end Math;
> 
> Output is "tanh(0.5) is 4.62117E-01", is that OK?
> 
> > ANSI/MIL-STD-1815A-1983
> 
> Of course, if you're using Ada83 this particular solution won't help
> you -- but then, you said you're using ActiveAda --

I believe ActivAda is an Ada 83 compiler; ObjectAda is the Ada 95
successor.  If you weren't short of time, I'd suggest upgrading.

I don't currently have access to ActivAda, but the example should
probably be something like this:

with Text_Io;
with Generic_Elementary_Functions;
procedure Math is
  package Float_Text_Io is new Text_IO.Float_IO(Float);
  package Funcs is new Generic_Elementary_Functions (Float);
  X : Float := 0.5;
  Y : Float;
begin
  Y := Funcs.Tanh (X);
  Text_Io.Put ("tanh(0.5) is");
  Float_Text_Io.Put (Y);
  Text_Io.New_Line;
end Math;

Note that ActivAda's library management scheme is a bit more complicated
than that of most Ada 95 compilers.  Read the manual carefully for
instructions on making Generic_Elementary_Functions visible and available
to your program.

If that still doesn't work, post the *exact* error message you get when
you try to build the above example program.  (If I got something wrong,
fix whatever bugs you can and re-post the example.)  I'm sure someone
familiar with ActivAda will then be able to help you.

If all else fails, you might try using the tanh() function from the C
math library.  Remember that the C declaration of tanh() is

    double tanh(double x);

C's type double typically corresponds to Ada's Long_Float, not Float.
In Ada 95, the declaration would be

    function tanh(X: Interfaces.C.Double) return Interfaces.C.Double;
    pragma Import(C, tanh, "tanh");

For ActivAda, you'll need to use the Ada 83 pragma Interface and/or
some implementation-defined pragma(s).  You may also need to give
extra arguments to the linker so it can find the math library.  See the
documentation for details.

"DRD Woodward" <doig@mwangi.demon.co.uk> also wrote:
> Another example of how reading and following clear instructions is a load of
> bollocks.Who writes this crap.Who has the nerve to sell it.!!

That would be the people who are most willing and able to help you with
your problem, and whom you've just insulted when you most desperately
need their assistance.

Have a nice day.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
San Diego, California, USA
"Simba, you have forgotten me.  I am your father.  This is CNN." -- JEJ




  reply	other threads:[~1997-10-18  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-18  0:00 Maths LIb DRD Woodward
1997-10-18  0:00 ` Simon Wright
1997-10-18  0:00   ` Keith Thompson [this message]
1997-10-19  0:00 ` Tom Moran
1997-10-23  0:00 ` Marc Bejerano
replies disabled

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