1 | /****************************************************************************/ |
---|
2 | /* MATHFNS.H: header file for system and zeno math functions; assumes role */ |
---|
3 | /* of math.h. Defines real-valued synonyms for system functions (eg, rsqrt */ |
---|
4 | /* for square root) and zeno functions (eg, seval), depending on precision */ |
---|
5 | /* switch (MIXEDPREC, SINGLEPREC, or DOUBLEPREC). */ |
---|
6 | /* Copyright (c) 2001 by Joshua E. Barnes, Honolulu, Hawai`i. */ |
---|
7 | /****************************************************************************/ |
---|
8 | |
---|
9 | #ifndef _mathfns_h |
---|
10 | #define _mathfns_h |
---|
11 | |
---|
12 | #include <math.h> |
---|
13 | |
---|
14 | /* |
---|
15 | * System math functions. Use double-precision versions in mixed or |
---|
16 | * double precision, and single-precisions versions otherwise. |
---|
17 | */ |
---|
18 | |
---|
19 | #if defined(MIXEDPREC) || defined(DOUBLEPREC) |
---|
20 | #define rsqrt sqrt |
---|
21 | #define rcbrt cbrt |
---|
22 | #define rsin sin |
---|
23 | #define rcos cos |
---|
24 | #define rtan tan |
---|
25 | #define rasin asin |
---|
26 | #define racos acos |
---|
27 | #define ratan atan |
---|
28 | #define ratan2 atan2 |
---|
29 | #define rlog log |
---|
30 | #define rexp exp |
---|
31 | #define rlog10 log10 |
---|
32 | #define rsinh sinh |
---|
33 | #define rcosh cosh |
---|
34 | #define rtanh tanh |
---|
35 | #define rpow pow |
---|
36 | #define rabs fabs |
---|
37 | #define rfloor floor |
---|
38 | #define rceil ceil |
---|
39 | #endif |
---|
40 | |
---|
41 | #if defined(SINGLEPREC) |
---|
42 | |
---|
43 | #if !defined(LINUX) |
---|
44 | |
---|
45 | #define rsqrt fsqrt |
---|
46 | #define rsin fsin |
---|
47 | #define rcos fcos |
---|
48 | #define rtan ftan |
---|
49 | #define rasin fasin |
---|
50 | #define racos facos |
---|
51 | #define ratan fatan |
---|
52 | #define ratan2 fatan2 |
---|
53 | #define rlog flog |
---|
54 | #define rexp fexp |
---|
55 | #define rlog10 log10f |
---|
56 | #define rsinh fsinh |
---|
57 | #define rcosh fcosh |
---|
58 | #define rtanh ftanh |
---|
59 | #define rpow powf |
---|
60 | #define rabs fabsf |
---|
61 | #define rfloor ffloor |
---|
62 | #define rceil fceil |
---|
63 | |
---|
64 | #else |
---|
65 | |
---|
66 | #define rsqrt sqrtf |
---|
67 | #define rsin sinf |
---|
68 | #define rcos cosf |
---|
69 | #define rtan tanf |
---|
70 | #define rasin asinf |
---|
71 | #define racos acosf |
---|
72 | #define ratan atanf |
---|
73 | #define ratan2 atan2f |
---|
74 | #define rlog logf |
---|
75 | #define rexp expf |
---|
76 | #define rlog10 log10f |
---|
77 | #define rsinh sinhf |
---|
78 | #define rcosh coshf |
---|
79 | #define rtanh tanhf |
---|
80 | #define rpow powf |
---|
81 | #define rabs fabsf |
---|
82 | #define rfloor floorf |
---|
83 | #define rceil ceilf |
---|
84 | |
---|
85 | #endif |
---|
86 | |
---|
87 | #endif |
---|
88 | |
---|
89 | /* |
---|
90 | * Functions in mathfns.c; invoked just like those above. |
---|
91 | */ |
---|
92 | |
---|
93 | #if defined(MIXEDPREC) || defined(DOUBLEPREC) |
---|
94 | #define rsqr sqr |
---|
95 | #define rqbe qbe |
---|
96 | #define rlog2 log2 |
---|
97 | #define rexp2 exp2 |
---|
98 | #define rdex dex |
---|
99 | #endif |
---|
100 | |
---|
101 | #if defined(SINGLEPREC) |
---|
102 | #define rsqr fsqr |
---|
103 | #define rqbe fqbe |
---|
104 | #define rlog2 flog2 |
---|
105 | #define rexp2 fexp2 |
---|
106 | #define rdex fdex |
---|
107 | #define rcbrt fcbrt |
---|
108 | #endif |
---|
109 | |
---|
110 | real rsqr(real); |
---|
111 | real rqbe(real); |
---|
112 | real rlog2(real); |
---|
113 | real rexp2(real); |
---|
114 | real rdex(real); |
---|
115 | |
---|
116 | #if defined(SINGLEPREC) |
---|
117 | float rcbrt(float); |
---|
118 | #endif |
---|
119 | |
---|
120 | /* |
---|
121 | * Random number functions available only in double precision. |
---|
122 | */ |
---|
123 | |
---|
124 | double xrandom(double, double); |
---|
125 | double grandom(double, double); |
---|
126 | |
---|
127 | /* |
---|
128 | * Functions which traffic in pointers to real values must be provided |
---|
129 | * in all three variants. |
---|
130 | */ |
---|
131 | |
---|
132 | #if defined(MIXEDPREC) |
---|
133 | #define pickshell mpickshell |
---|
134 | #define pickball mpickball |
---|
135 | #define pickbox mpickbox |
---|
136 | #endif |
---|
137 | |
---|
138 | #if defined(DOUBLEPREC) |
---|
139 | #define pickshell dpickshell |
---|
140 | #define pickball dpickball |
---|
141 | #define pickbox dpickbox |
---|
142 | #endif |
---|
143 | |
---|
144 | #if defined(SINGLEPREC) |
---|
145 | #define pickshell fpickshell |
---|
146 | #define pickball fpickball |
---|
147 | #define pickbox fpickbox |
---|
148 | #endif |
---|
149 | |
---|
150 | /* Functions in pickpnt.c */ |
---|
151 | |
---|
152 | void pickshell(real *, int, real); |
---|
153 | void pickball(real *, int, real); |
---|
154 | void pickbox(real *, int, real); |
---|
155 | |
---|
156 | #endif /* ! _mathfns_h */ |
---|