1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . N U M E R I C S . A U X --
8 -- (Apple OS X Version) --
10 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
35 -- This version is for use with normal Unix math functions, except for
36 -- sine/cosine which have been implemented directly in Ada to get
37 -- the required accuracy in OS X. Alternative packages are used
38 -- on OpenVMS (different import names), VxWorks (no need for the
39 -- -lm Linker_Options), and on the x86 (where we have two
40 -- versions one using inline ASM, and one importing from the C long
41 -- routines that take 80-bit arguments).
43 package Ada
.Numerics
.Aux
is
46 pragma Linker_Options
("-lm");
48 type Double
is digits 15;
49 -- Type Double is the type used to call the C routines
51 -- The following functions have been implemented in Ada, since
52 -- the OS X math library didn't meet accuracy requirements for
53 -- argument reduction. The implementation here has been tailored
54 -- to match Ada strict mode Numerics requirements while maintaining
55 -- maximum efficiency.
56 function Sin
(X
: Double
) return Double
;
59 function Cos
(X
: Double
) return Double
;
62 -- We import these functions directly from C. Note that we label them
63 -- all as pure functions, because indeed all of them are in fact pure!
65 function Tan
(X
: Double
) return Double
;
66 pragma Import
(C
, Tan
, "tan");
67 pragma Pure_Function
(Tan
);
69 function Exp
(X
: Double
) return Double
;
70 pragma Import
(C
, Exp
, "exp");
71 pragma Pure_Function
(Exp
);
73 function Sqrt
(X
: Double
) return Double
;
74 pragma Import
(C
, Sqrt
, "sqrt");
75 pragma Pure_Function
(Sqrt
);
77 function Log
(X
: Double
) return Double
;
78 pragma Import
(C
, Log
, "log");
79 pragma Pure_Function
(Log
);
81 function Acos
(X
: Double
) return Double
;
82 pragma Import
(C
, Acos
, "acos");
83 pragma Pure_Function
(Acos
);
85 function Asin
(X
: Double
) return Double
;
86 pragma Import
(C
, Asin
, "asin");
87 pragma Pure_Function
(Asin
);
89 function Atan
(X
: Double
) return Double
;
90 pragma Import
(C
, Atan
, "atan");
91 pragma Pure_Function
(Atan
);
93 function Sinh
(X
: Double
) return Double
;
94 pragma Import
(C
, Sinh
, "sinh");
95 pragma Pure_Function
(Sinh
);
97 function Cosh
(X
: Double
) return Double
;
98 pragma Import
(C
, Cosh
, "cosh");
99 pragma Pure_Function
(Cosh
);
101 function Tanh
(X
: Double
) return Double
;
102 pragma Import
(C
, Tanh
, "tanh");
103 pragma Pure_Function
(Tanh
);
105 function Pow
(X
, Y
: Double
) return Double
;
106 pragma Import
(C
, Pow
, "pow");
107 pragma Pure_Function
(Pow
);
109 end Ada
.Numerics
.Aux
;