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,bf11afc1c11f3d84 X-Google-Attributes: gid103376,public From: kst@king.cts.com (Keith Thompson) Subject: Re: Maths LIb Date: 1997/10/18 Message-ID: <877210437.50807@wagasa.cts.com>#1/1 X-Deja-AN: 281609514 References: <877175772.10098.0.nnrp-08.9e988f8e@news.demon.co.uk> Cache-Post-Path: wagasa.cts.com!kst@king.cts.com Organization: CTS Network Services Newsgroups: comp.lang.ada Date: 1997-10-18T00:00:00+00:00 List-Id: Simon Wright (simon@pogner.demon.co.uk) wrote: > "DRD Woodward" 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" 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