comp.lang.ada
 help / color / mirror / Atom feed
* problems with log function
@ 2003-12-23 12:12 Jorge Su?rez-Sol?s Rivaya
  2003-12-23 17:26 ` Stephen Leake
  0 siblings, 1 reply; 3+ messages in thread
From: Jorge Su?rez-Sol?s Rivaya @ 2003-12-23 12:12 UTC (permalink / raw)


hi, this is my first post.
First of all 'hi' to every body, my name is Jorge and Im from Spain.

I have a problem with the log function.

I have made an instantion of the generic package
Ada.Numerics.Generic_Elementary_Function for Floats something like
this:

package Math is new Ada.Numerics.Generic_Elementary_Function(Float);
use Math;

and when i use it a say: log(Y)   
Y is a float of course. I do not have any compilation problem, but
when I execute it I get an Ada.Numerics.Argument_Error if Y is higher
than 1.0

I do not understand it. 

Please HELP ME

Thanks all

Jorge Su�rez-Sol�s Rivaya



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problems with log function
  2003-12-23 12:12 problems with log function Jorge Su?rez-Sol?s Rivaya
@ 2003-12-23 17:26 ` Stephen Leake
  2003-12-24  8:50   ` Jorge Su?rez-Sol?s Rivaya
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Leake @ 2003-12-23 17:26 UTC (permalink / raw)
  To: comp.lang.ada

jsuarezrivaya@yahoo.es (Jorge Su?rez-Sol?s Rivaya) writes:

> hi, this is my first post.

Welcome!

> 
> First of all 'hi' to every body, my name is Jorge and Im from Spain.
> 
> I have a problem with the log function.
> 
> I have made an instantion of the generic package
> Ada.Numerics.Generic_Elementary_Function for Floats something like
> this:
> 
> package Math is new Ada.Numerics.Generic_Elementary_Function(Float);
> use Math;
> 
> and when i use it a say: log(Y)   
> Y is a float of course. I do not have any compilation problem, but
> when I execute it I get an Ada.Numerics.Argument_Error if Y is higher
> than 1.0

It helps if you post a compilable example to show your problem. Often
the problem is not what you think it is; having the real source lets
us see what is really going on for you.

Since this is your first post, and I'm on lunch break, I wrote one for
you:

with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_Io; use Ada.Text_Io;
procedure Jorge
is
   package Math is new Ada.Numerics.Generic_Elementary_Functions (Float);
   use Math;

   X : Float;

begin
   Put_Line ("x     log (x)");
   for Y in 1 .. 10 loop
      X := 0.2 * Float (Y);
      Put_Line (Float'Image (X) & "  " & Float'Image (Log (X)));
   end loop;

end Jorge;

Compiling and running this with GNAT 5.01a on Windows 2000, I get:

make -r jorge.run
gnatmake -k -O3 -gnatn -gnatwa -I.. jorge -largs   -bargs  -cargs 
gcc -c -I./ -O3 -gnatn -gnatwa -I.. -I- ..\jorge.adb
gnatbind -aO./ -I.. -I- -x jorge.ali
gnatlink jorge.ali
./jorge.exe 
x     log (x)
 2.00000E-01  -1.60944E+00
 4.00000E-01  -9.16291E-01
 6.00000E-01  -5.10826E-01
 8.00000E-01  -2.23144E-01
 1.00000E+00   0.00000E+00
 1.20000E+00   1.82322E-01
 1.40000E+00   3.36472E-01
 1.60000E+00   4.70004E-01
 1.80000E+00   5.87787E-01
 2.00000E+00   6.93147E-01

I didn't check the numbers, but I assume they are correct. In any
case, no constraint errors.

It may be that log is actually broken on your platform; please tell us
what compiler and operating system you are using.

Hope this helps.

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problems with log function
  2003-12-23 17:26 ` Stephen Leake
@ 2003-12-24  8:50   ` Jorge Su?rez-Sol?s Rivaya
  0 siblings, 0 replies; 3+ messages in thread
From: Jorge Su?rez-Sol?s Rivaya @ 2003-12-24  8:50 UTC (permalink / raw)


Thank you very much, you are rigth, I have tried the programa on
another platform and it works, ... I was using the compiler version
which comes with Mandrake 9.1.

Anyway it works, thank you again.

Jorge

------------------------------------------------------------------------------
Stephen Leake <Stephe.Leake@nasa.gov> wrote in message news:<mailman.174.1072200377.31149.comp.lang.ada@ada-france.org>...
> jsuarezrivaya@yahoo.es (Jorge Su�rez-Sol�s Rivaya) writes:
> 
> > hi, this is my first post.
> 
> Welcome!
> 
> > 
> > First of all 'hi' to every body, my name is Jorge and Im from Spain.
> > 
> > I have a problem with the log function.
> > 
> > I have made an instantion of the generic package
> > Ada.Numerics.Generic_Elementary_Function for Floats something like
> > this:
> > 
> > package Math is new Ada.Numerics.Generic_Elementary_Function(Float);
> > use Math;
> > 
> > and when i use it a say: log(Y)   
> > Y is a float of course. I do not have any compilation problem, but
> > when I execute it I get an Ada.Numerics.Argument_Error if Y is higher
> > than 1.0
> 
> It helps if you post a compilable example to show your problem. Often
> the problem is not what you think it is; having the real source lets
> us see what is really going on for you.
> 
> Since this is your first post, and I'm on lunch break, I wrote one for
> you:
> 
> with Ada.Numerics.Generic_Elementary_Functions;
> with Ada.Text_Io; use Ada.Text_Io;
> procedure Jorge
> is
>    package Math is new Ada.Numerics.Generic_Elementary_Functions (Float);
>    use Math;
> 
>    X : Float;
> 
> begin
>    Put_Line ("x     log (x)");
>    for Y in 1 .. 10 loop
>       X := 0.2 * Float (Y);
>       Put_Line (Float'Image (X) & "  " & Float'Image (Log (X)));
>    end loop;
> 
> end Jorge;
> 
> Compiling and running this with GNAT 5.01a on Windows 2000, I get:
> 
> make -r jorge.run
> gnatmake -k -O3 -gnatn -gnatwa -I.. jorge -largs   -bargs  -cargs 
> gcc -c -I./ -O3 -gnatn -gnatwa -I.. -I- ..\jorge.adb
> gnatbind -aO./ -I.. -I- -x jorge.ali
> gnatlink jorge.ali
> ./jorge.exe 
> x     log (x)
>  2.00000E-01  -1.60944E+00
>  4.00000E-01  -9.16291E-01
>  6.00000E-01  -5.10826E-01
>  8.00000E-01  -2.23144E-01
>  1.00000E+00   0.00000E+00
>  1.20000E+00   1.82322E-01
>  1.40000E+00   3.36472E-01
>  1.60000E+00   4.70004E-01
>  1.80000E+00   5.87787E-01
>  2.00000E+00   6.93147E-01
> 
> I didn't check the numbers, but I assume they are correct. In any
> case, no constraint errors.
> 
> It may be that log is actually broken on your platform; please tell us
> what compiler and operating system you are using.
> 
> Hope this helps.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-24  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-23 12:12 problems with log function Jorge Su?rez-Sol?s Rivaya
2003-12-23 17:26 ` Stephen Leake
2003-12-24  8:50   ` Jorge Su?rez-Sol?s Rivaya

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