]> www.ginac.de Git - cln.git/blob - include/cl_float.h
6cf021566ec8b28dbabd1f3437622ae391308a91
[cln.git] / include / cl_float.h
1 // Public float operations.
2
3 #ifndef _CL_FLOAT_H
4 #define _CL_FLOAT_H
5
6 #include "cl_number.h"
7 #include "cl_float_class.h"
8 #include "cl_floatformat.h"
9 #include "cl_random.h"
10 #include "cl_integer_class.h"
11 #include "cl_sfloat_class.h"
12 #include "cl_ffloat_class.h"
13 #include "cl_dfloat_class.h"
14 #include "cl_lfloat_class.h"
15
16
17 CL_DEFINE_AS_CONVERSION(cl_F)
18
19
20 // Return type for integer_decode_float:
21 struct cl_idecoded_float {
22         cl_I mantissa;
23         cl_I exponent;
24         cl_I sign;
25 // Constructor.
26         cl_idecoded_float () {}
27         cl_idecoded_float (const cl_I& m, const cl_I& e, const cl_I& s) : mantissa(m), exponent(e), sign(s) {}
28 };
29
30
31 // zerop(x) testet, ob (= x 0).
32 extern cl_boolean zerop (const cl_F& x);
33
34 // minusp(x) testet, ob (< x 0).
35 extern cl_boolean minusp (const cl_F& x);
36
37 // plusp(x) testet, ob (> x 0).
38 extern cl_boolean plusp (const cl_F& x);
39
40
41 // cl_F_to_SF(x) wandelt ein Float x in ein Short-Float um und rundet dabei.
42 extern const cl_SF cl_F_to_SF (const cl_F& x);
43
44 // cl_F_to_FF(x) wandelt ein Float x in ein Single-Float um und rundet dabei.
45 extern const cl_FF cl_F_to_FF (const cl_F& x);
46
47 // cl_F_to_DF(x) wandelt ein Float x in ein Double-Float um und rundet dabei.
48 extern const cl_DF cl_F_to_DF (const cl_F& x);
49
50 // cl_F_to_LF(x,len) wandelt ein Float x in ein Long-Float mit len Digits um
51 // und rundet dabei.
52 // > uintC len: gewünschte Anzahl Digits, >=LF_minlen
53 extern const cl_LF cl_F_to_LF (const cl_F& x, uintC len);
54
55
56 // The default float format used when converting rational numbers to floats.
57 extern cl_float_format_t cl_default_float_format;
58
59 // Returns the smallest float format which guarantees at least n decimal digits
60 // in the mantissa (after the decimal point).
61 extern cl_float_format_t cl_float_format (uintL n);
62
63 // cl_float(x,y) wandelt ein Float x in das Float-Format des Floats y um
64 // und rundet dabei nötigenfalls.
65 // > x,y: Floats
66 // < ergebnis: (float x y)
67 extern const cl_F cl_float (const cl_F& x, const cl_F& y);
68
69 // cl_float(x,f) wandelt ein Float x in das Float-Format f um
70 // und rundet dabei nötigenfalls.
71 // > x: ein Float
72 // > f: eine Float-Format-Spezifikation
73 // < ergebnis: (float x f)
74 extern const cl_F cl_float (const cl_F& x, cl_float_format_t f);
75
76 // cl_float(x) wandelt eine reelle Zahl x in ein Float um
77 // und rundet dabei nötigenfalls.
78 // > x: eine reelle Zahl
79 // < ergebnis: (float x)
80 // Abhängig von cl_default_float_format.
81 inline const cl_F cl_float (const cl_F& x) { return x; }
82
83 // cl_float(x,y) wandelt ein Integer x in das Float-Format des Floats y um
84 // und rundet dabei nötigenfalls.
85 // > x: ein Integer
86 // > y: ein Float
87 // < ergebnis: (float x y)
88 extern const cl_F cl_float (const cl_I& x, const cl_F& y);
89
90 // cl_float(x,y) wandelt ein Integer x in das Float-Format f um
91 // und rundet dabei nötigenfalls.
92 // > x: ein Integer
93 // > f: eine Float-Format-Spezifikation
94 // < ergebnis: (float x f)
95 extern const cl_F cl_float (const cl_I& x, cl_float_format_t f);
96
97 // cl_float(x) wandelt ein Integer x in ein Float um und rundet dabei.
98 // > x: ein Integer
99 // < ergebnis: (float x)
100 // Abhängig von cl_default_float_format.
101 extern const cl_F cl_float (const cl_I& x);
102
103 // cl_float(x,y) wandelt eine rationale Zahl x in das Float-Format des
104 // Floats y um und rundet dabei nötigenfalls.
105 // > x: eine rationale Zahl
106 // > y: ein Float
107 // < ergebnis: (float x y)
108 extern const cl_F cl_float (const cl_RA& x, const cl_F& y);
109
110 // cl_float(x,y) wandelt eine rationale Zahl x in das Float-Format f um
111 // und rundet dabei nötigenfalls.
112 // > x: eine rationale Zahl
113 // > f: eine Float-Format-Spezifikation
114 // < ergebnis: (float x f)
115 extern const cl_F cl_float (const cl_RA& x, cl_float_format_t f);
116
117 // cl_float(x) wandelt eine rationale Zahl x in ein Float um und rundet dabei.
118 // > x: eine rationale Zahl
119 // < ergebnis: (float x)
120 // Abhängig von cl_default_float_format.
121 extern const cl_F cl_float (const cl_RA& x);
122
123 // The C++ compilers are not clever enough to guess this:
124 inline const cl_F cl_float (int x, const cl_F& y)
125         { return cl_float(cl_I(x),y); }
126 inline const cl_F cl_float (unsigned int x, const cl_F& y)
127         { return cl_float(cl_I(x),y); }
128 inline const cl_F cl_float (int x, cl_float_format_t y)
129         { return cl_float(cl_I(x),y); }
130 inline const cl_F cl_float (unsigned int x, cl_float_format_t y)
131         { return cl_float(cl_I(x),y); }
132 inline const cl_F cl_float (int x)
133         { return cl_float(cl_I(x)); }
134 inline const cl_F cl_float (unsigned int x)
135         { return cl_float(cl_I(x)); }
136 // The C++ compilers could hardly guess the following:
137 inline const cl_F cl_float (float x, const cl_F& y)
138         { return cl_float(cl_FF(x),y); }
139 inline const cl_F cl_float (double x, const cl_F& y)
140         { return cl_float(cl_DF(x),y); }
141 inline const cl_F cl_float (float x, cl_float_format_t y)
142         { return cl_float(cl_FF(x),y); }
143 inline const cl_F cl_float (double x, cl_float_format_t y)
144         { return cl_float(cl_DF(x),y); }
145 inline const cl_F cl_float (float x)
146         { return cl_float(cl_FF(x)); }
147 inline const cl_F cl_float (double x)
148         { return cl_float(cl_DF(x)); }
149
150
151 // Liefert (- x), wo x ein Float ist.
152 extern const cl_F operator- (const cl_F& x);
153
154 // Liefert (+ x y), wo x und y Floats sind.
155 extern const cl_F operator+ (const cl_F& x, const cl_F& y);
156 // The C++ compilers could hardly guess the following:
157 inline const cl_F operator+ (const cl_RA& x, const cl_F& y)
158         { return cl_float(x,y) + y; }
159 inline const cl_F operator+ (const cl_I& x, const cl_F& y)
160         { return cl_float(x,y) + y; }
161 inline const cl_F operator+ (const cl_F& x, const cl_RA& y)
162         { return x + cl_float(y,x); }
163 inline const cl_F operator+ (const cl_F& x, const cl_I& y)
164         { return x + cl_float(y,x); }
165 // Dem C++-Compiler muß man nun auch das Folgende sagen:
166 inline const cl_F operator+ (const int x, const cl_F& y)
167         { return cl_I(x) + y; }
168 inline const cl_F operator+ (const unsigned int x, const cl_F& y)
169         { return cl_I(x) + y; }
170 inline const cl_F operator+ (const long x, const cl_F& y)
171         { return cl_I(x) + y; }
172 inline const cl_F operator+ (const unsigned long x, const cl_F& y)
173         { return cl_I(x) + y; }
174 inline const cl_F operator+ (const cl_F& x, const int y)
175         { return x + cl_I(y); }
176 inline const cl_F operator+ (const cl_F& x, const unsigned int y)
177         { return x + cl_I(y); }
178 inline const cl_F operator+ (const cl_F& x, const long y)
179         { return x + cl_I(y); }
180 inline const cl_F operator+ (const cl_F& x, const unsigned long y)
181         { return x + cl_I(y); }
182
183 // Liefert (- x y), wo x und y Floats sind.
184 extern const cl_F operator- (const cl_F& x, const cl_F& y);
185 // The C++ compilers could hardly guess the following:
186 inline const cl_F operator- (const cl_RA& x, const cl_F& y)
187         { return cl_float(x,y) - y; }
188 inline const cl_F operator- (const cl_I& x, const cl_F& y)
189         { return cl_float(x,y) - y; }
190 inline const cl_F operator- (const cl_F& x, const cl_RA& y)
191         { return x - cl_float(y,x); }
192 inline const cl_F operator- (const cl_F& x, const cl_I& y)
193         { return x - cl_float(y,x); }
194 // Dem C++-Compiler muß man nun auch das Folgende sagen:
195 inline const cl_F operator- (const int x, const cl_F& y)
196         { return cl_I(x) - y; }
197 inline const cl_F operator- (const unsigned int x, const cl_F& y)
198         { return cl_I(x) - y; }
199 inline const cl_F operator- (const long x, const cl_F& y)
200         { return cl_I(x) - y; }
201 inline const cl_F operator- (const unsigned long x, const cl_F& y)
202         { return cl_I(x) - y; }
203 inline const cl_F operator- (const cl_F& x, const int y)
204         { return x - cl_I(y); }
205 inline const cl_F operator- (const cl_F& x, const unsigned int y)
206         { return x - cl_I(y); }
207 inline const cl_F operator- (const cl_F& x, const long y)
208         { return x - cl_I(y); }
209 inline const cl_F operator- (const cl_F& x, const unsigned long y)
210         { return x - cl_I(y); }
211
212 // Liefert (* x y), wo x und y Floats sind.
213 extern const cl_F operator* (const cl_F& x, const cl_F& y);
214 // Spezialfall x oder y Integer oder rationale Zahl.
215 inline const cl_R operator* (const cl_F& x, const cl_I& y)
216 {
217         extern const cl_R cl_F_I_mul (const cl_F&, const cl_I&);
218         return cl_F_I_mul(x,y);
219 }
220 inline const cl_R operator* (const cl_I& x, const cl_F& y)
221 {
222         extern const cl_R cl_F_I_mul (const cl_F&, const cl_I&);
223         return cl_F_I_mul(y,x);
224 }
225 inline const cl_R operator* (const cl_F& x, const cl_RA& y)
226 {
227         extern const cl_R cl_F_RA_mul (const cl_F&, const cl_RA&);
228         return cl_F_RA_mul(x,y);
229 }
230 inline const cl_R operator* (const cl_RA& x, const cl_F& y)
231 {
232         extern const cl_R cl_F_RA_mul (const cl_F&, const cl_RA&);
233         return cl_F_RA_mul(y,x);
234 }
235 // Dem C++-Compiler muß man nun auch das Folgende sagen:
236 inline const cl_R operator* (const int x, const cl_F& y)
237         { return cl_I(x) * y; }
238 inline const cl_R operator* (const unsigned int x, const cl_F& y)
239         { return cl_I(x) * y; }
240 inline const cl_R operator* (const long x, const cl_F& y)
241         { return cl_I(x) * y; }
242 inline const cl_R operator* (const unsigned long x, const cl_F& y)
243         { return cl_I(x) * y; }
244 inline const cl_R operator* (const cl_F& x, const int y)
245         { return x * cl_I(y); }
246 inline const cl_R operator* (const cl_F& x, const unsigned int y)
247         { return x * cl_I(y); }
248 inline const cl_R operator* (const cl_F& x, const long y)
249         { return x * cl_I(y); }
250 inline const cl_R operator* (const cl_F& x, const unsigned long y)
251         { return x * cl_I(y); }
252
253 // Liefert (* x x), wo x ein Float ist.
254 extern const cl_F square (const cl_F& x);
255
256 // Liefert (/ x y), wo x und y Floats sind.
257 extern const cl_F operator/ (const cl_F& x, const cl_F& y);
258 // Liefert (/ x y), wo x und y ein Float und eine rationale Zahl sind.
259 extern const cl_F operator/ (const cl_F& x, const cl_RA& y);
260 extern const cl_F operator/ (const cl_F& x, const cl_I& y);
261 extern const cl_R operator/ (const cl_RA& x, const cl_F& y);
262 extern const cl_R operator/ (const cl_I& x, const cl_F& y);
263 // The C++ compilers could hardly guess the following:
264 inline const cl_F operator/ (const cl_F& x, const int y)
265         { return x / cl_I(y); }
266 inline const cl_F operator/ (const cl_F& x, const unsigned int y)
267         { return x / cl_I(y); }
268 inline const cl_F operator/ (const cl_F& x, const long y)
269         { return x / cl_I(y); }
270 inline const cl_F operator/ (const cl_F& x, const unsigned long y)
271         { return x / cl_I(y); }
272 inline const cl_R operator/ (const int x, const cl_F& y)
273         { return cl_I(x) / y; }
274 inline const cl_R operator/ (const unsigned int x, const cl_F& y)
275         { return cl_I(x) / y; }
276 inline const cl_R operator/ (const long x, const cl_F& y)
277         { return cl_I(x) / y; }
278 inline const cl_R operator/ (const unsigned long x, const cl_F& y)
279         { return cl_I(x) / y; }
280
281 // Liefert (abs x), wo x ein Float ist.
282 extern const cl_F abs (const cl_F& x);
283
284 // Liefert zu einem Float x>=0 : (sqrt x), ein Float.
285 extern const cl_F sqrt (const cl_F& x);
286
287 // recip(x) liefert (/ x), wo x ein Float ist.
288 extern const cl_F recip (const cl_F& x);
289
290 // (1+ x), wo x ein Float ist.
291 inline const cl_F plus1 (const cl_F& x) // { return x + cl_I(1); }
292 {
293         return x + cl_float(1,x);
294 }
295
296 // (1- x), wo x ein Float ist.
297 inline const cl_F minus1 (const cl_F& x) // { return x + cl_I(-1); }
298 {
299         return x + cl_float(-1,x);
300 }
301
302 // cl_compare(x,y) vergleicht zwei Floats x und y.
303 // Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
304 extern cl_signean cl_compare (const cl_F& x, const cl_F& y);
305
306 // cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
307 extern uint32 cl_equal_hashcode (const cl_F& x);
308
309 inline bool operator== (const cl_F& x, const cl_F& y)
310         { return cl_compare(x,y)==0; }
311 inline bool operator!= (const cl_F& x, const cl_F& y)
312         { return cl_compare(x,y)!=0; }
313 inline bool operator<= (const cl_F& x, const cl_F& y)
314         { return cl_compare(x,y)<=0; }
315 inline bool operator< (const cl_F& x, const cl_F& y)
316         { return cl_compare(x,y)<0; }
317 inline bool operator>= (const cl_F& x, const cl_F& y)
318         { return cl_compare(x,y)>=0; }
319 inline bool operator> (const cl_F& x, const cl_F& y)
320         { return cl_compare(x,y)>0; }
321
322
323 // ffloor(x) liefert (ffloor x), wo x ein Float ist.
324 extern const cl_F ffloor (const cl_F& x);
325
326 // fceiling(x) liefert (fceiling x), wo x ein Float ist.
327 extern const cl_F fceiling (const cl_F& x);
328
329 // ftruncate(x) liefert (ftruncate x), wo x ein Float ist.
330 extern const cl_F ftruncate (const cl_F& x);
331
332 // fround(x) liefert (fround x), wo x ein Float ist.
333 extern const cl_F fround (const cl_F& x);
334
335
336 // Return type for frounding operators.
337 // x / y  --> (q,r) with x = y*q+r.
338 struct cl_F_fdiv_t {
339         cl_F quotient;
340         cl_F remainder;
341 // Constructor.
342         cl_F_fdiv_t () {}
343         cl_F_fdiv_t (const cl_F& q, const cl_F& r) : quotient(q), remainder(r) {}
344 };
345
346 // ffloor2(x) liefert (ffloor x), wo x ein F ist.
347 extern const cl_F_fdiv_t ffloor2 (const cl_F& x);
348
349 // fceiling2(x) liefert (fceiling x), wo x ein F ist.
350 extern const cl_F_fdiv_t fceiling2 (const cl_F& x);
351
352 // ftruncate2(x) liefert (ftruncate x), wo x ein F ist.
353 extern const cl_F_fdiv_t ftruncate2 (const cl_F& x);
354
355 // fround2(x) liefert (fround x), wo x ein F ist.
356 extern const cl_F_fdiv_t fround2 (const cl_F& x);
357
358
359 // Return type for rounding operators.
360 // x / y  --> (q,r) with x = y*q+r.
361 struct cl_F_div_t {
362         cl_I quotient;
363         cl_F remainder;
364 // Constructor.
365         cl_F_div_t () {}
366         cl_F_div_t (const cl_I& q, const cl_F& r) : quotient(q), remainder(r) {}
367 };
368
369 // floor2(x) liefert (floor x), wo x ein F ist.
370 extern const cl_F_div_t floor2 (const cl_F& x);
371 extern const cl_I floor1 (const cl_F& x);
372
373 // ceiling2(x) liefert (ceiling x), wo x ein F ist.
374 extern const cl_F_div_t ceiling2 (const cl_F& x);
375 extern const cl_I ceiling1 (const cl_F& x);
376
377 // truncate2(x) liefert (truncate x), wo x ein F ist.
378 extern const cl_F_div_t truncate2 (const cl_F& x);
379 extern const cl_I truncate1 (const cl_F& x);
380
381 // round2(x) liefert (round x), wo x ein F ist.
382 extern const cl_F_div_t round2 (const cl_F& x);
383 extern const cl_I round1 (const cl_F& x);
384
385 // floor2(x,y) liefert (floor x y), wo x und y Floats sind.
386 extern const cl_F_div_t floor2 (const cl_F& x, const cl_F& y);
387 inline const cl_I floor1 (const cl_F& x, const cl_F& y) { return floor1(x/y); }
388
389 // ceiling2(x,y) liefert (ceiling x y), wo x und y Floats sind.
390 extern const cl_F_div_t ceiling2 (const cl_F& x, const cl_F& y);
391 inline const cl_I ceiling1 (const cl_F& x, const cl_F& y) { return ceiling1(x/y); }
392
393 // truncate2(x,y) liefert (truncate x y), wo x und y Floats sind.
394 extern const cl_F_div_t truncate2 (const cl_F& x, const cl_F& y);
395 inline const cl_I truncate1 (const cl_F& x, const cl_F& y) { return truncate1(x/y); }
396
397 // round2(x,y) liefert (round x y), wo x und y Floats sind.
398 extern const cl_F_div_t round2 (const cl_F& x, const cl_F& y);
399 inline const cl_I round1 (const cl_F& x, const cl_F& y) { return round1(x/y); }
400
401
402 // Return type for decode_float:
403 struct cl_decoded_float {
404         cl_F mantissa;
405         cl_I exponent;
406         cl_F sign;
407 // Constructor.
408         cl_decoded_float () {}
409         cl_decoded_float (const cl_F& m, const cl_I& e, const cl_F& s) : mantissa(m), exponent(e), sign(s) {}
410 };
411
412 // decode_float(x) liefert zu einem Float x: (decode-float x).
413 // x = 0.0 liefert (0.0, 0, 1.0).
414 // x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
415 extern const cl_decoded_float decode_float (const cl_F& x);
416
417 // float_exponent(x) liefert zu einem Float x:
418 // den Exponenten von (decode-float x).
419 // x = 0.0 liefert 0.
420 // x = (-1)^s * 2^e * m liefert e.
421 extern sintL float_exponent (const cl_F& x);
422
423 // float_radix(x) liefert (float-radix x), wo x ein Float ist.
424 inline sintL float_radix (const cl_F& x)
425 {
426         (void)x; // unused x
427         return 2;
428 }
429
430 // float_sign(x) liefert (float-sign x), wo x ein Float ist.
431 extern const cl_F float_sign (const cl_F& x);
432
433 // float_sign(x,y) liefert (float-sign x y), wo x und y Floats sind.
434 extern const cl_F float_sign (const cl_F& x, const cl_F& y);
435
436 // float_digits(x) liefert (float-digits x), wo x ein Float ist.
437 // < ergebnis: ein uintL >0
438 extern uintL float_digits (const cl_F& x);
439
440 // float_precision(x) liefert (float-precision x), wo x ein Float ist.
441 // < ergebnis: ein uintL >=0
442 extern uintL float_precision (const cl_F& x);
443
444 // Returns the floating point format of a float.
445 inline cl_float_format_t cl_float_format (const cl_F& x)
446         { return (cl_float_format_t) float_digits(x); }
447
448
449 // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x).
450 // x = 0.0 liefert (0, 0, 1).
451 // x = (-1)^s * 2^e * m bei Float-Precision p liefert
452 //   (Mantisse 2^p * m als Integer, e-p als Integer, (-1)^s als Fixnum).
453 extern const cl_idecoded_float integer_decode_float (const cl_F& x);
454
455
456 // rational(x) liefert (rational x), wo x ein Float ist.
457 extern const cl_RA rational (const cl_F& x);
458
459
460 // scale_float(x,delta) liefert x*2^delta, wo x ein Float ist.
461 extern const cl_F scale_float (const cl_F& x, sintL delta);
462 extern const cl_F scale_float (const cl_F& x, const cl_I& delta);
463
464
465 // max(x,y) liefert (max x y), wo x und y Floats sind.
466 extern const cl_F max (const cl_F& x, const cl_F& y);
467
468 // min(x,y) liefert (min x y), wo x und y Floats sind.
469 extern const cl_F min (const cl_F& x, const cl_F& y);
470
471 // signum(x) liefert (signum x), wo x ein Float ist.
472 extern const cl_F signum (const cl_F& x);
473
474
475 // Returns the largest (most positive) floating point number in float format f.
476 extern const cl_F most_positive_float (cl_float_format_t f);
477 //CL_REQUIRE(cl_F_mostpos)
478
479 // Returns the smallest (most negative) floating point number in float format f.
480 extern const cl_F most_negative_float (cl_float_format_t f);
481 //CL_REQUIRE(cl_F_mostneg)
482
483 // Returns the least positive floating point number (i.e. > 0 but closest to 0)
484 // in float format f.
485 extern const cl_F least_positive_float (cl_float_format_t f);
486 //CL_REQUIRE(cl_F_leastpos)
487
488 // Returns the least negative floating point number (i.e. < 0 but closest to 0)
489 // in float format f.
490 extern const cl_F least_negative_float (cl_float_format_t f);
491 //CL_REQUIRE(cl_F_leastneg)
492
493 // Returns the smallest floating point number e > 0 such that 1+e != 1.
494 extern const cl_F float_epsilon (cl_float_format_t f);
495 //CL_REQUIRE(cl_F_epspos)
496
497 // Returns the smallest floating point number e > 0 such that 1-e != 1.
498 extern const cl_F float_negative_epsilon (cl_float_format_t f);
499 //CL_REQUIRE(cl_F_epsneg)
500
501
502 // Konversion zu einem C "float".
503 extern float cl_float_approx (const cl_F& x);
504
505 // Konversion zu einem C "double".
506 extern double cl_double_approx (const cl_F& x);
507
508
509 // Transcendental functions
510
511
512 // cl_pi(y) liefert die Zahl pi im selben Float-Format wie y.
513 // > y: ein Float
514 extern const cl_F cl_pi (const cl_F& y);
515
516 // cl_pi(y) liefert die Zahl pi im Float-Format f.
517 // > f: eine Float-Format-Spezifikation
518 extern const cl_F cl_pi (cl_float_format_t f);
519
520 // cl_pi() liefert die Zahl pi im Default-Float-Format.
521 extern const cl_F cl_pi (void);
522
523 //CL_REQUIRE(cl_F_pi_var)
524
525
526 // sin(x) liefert den Sinus (sin x) eines Float x.
527 extern const cl_F sin (const cl_F& x);
528
529 // cos(x) liefert den Cosinus (cos x) eines Float x.
530 extern const cl_F cos (const cl_F& x);
531
532 // Return type for cl_cos_sin():
533 struct cl_cos_sin_t {
534         cl_R cos;
535         cl_R sin;
536 // Constructor:
537         cl_cos_sin_t (const cl_R& u, const cl_R& v) : cos (u), sin (v) {}
538 };
539
540 // cl_cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
541 extern const cl_cos_sin_t cl_cos_sin (const cl_F& x);
542
543 // tan(x) liefert den Tangens (tan x) eines Float x.
544 extern const cl_F tan (const cl_F& x);
545
546
547 // cl_exp1(y) liefert die Zahl e = exp(1) im selben Float-Format wie y.
548 // > y: ein Float
549 extern const cl_F cl_exp1 (const cl_F& y);
550
551 // cl_exp1(y) liefert die Zahl e = exp(1) im Float-Format f.
552 // > f: eine Float-Format-Spezifikation
553 extern const cl_F cl_exp1 (cl_float_format_t f);
554
555 // cl_exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
556 extern const cl_F cl_exp1 (void);
557
558 //CL_REQUIRE(cl_F_exp1_var)
559
560
561 // ln(x) liefert zu einem Float x>0 die Zahl ln(x).
562 extern const cl_F ln (const cl_F& x);
563 // Spezialfall: x Long-Float -> Ergebnis Long-Float
564 inline const cl_LF ln (const cl_LF& x) { return The(cl_LF)(ln(The(cl_F)(x))); }
565
566 // exp(x) liefert zu einem Float x die Zahl exp(x).
567 extern const cl_F exp (const cl_F& x);
568
569 // sinh(x) liefert zu einem Float x die Zahl sinh(x).
570 extern const cl_F sinh (const cl_F& x);
571
572 // cosh(x) liefert zu einem Float x die Zahl cosh(x).
573 extern const cl_F cosh (const cl_F& x);
574
575 // Return type for cl_cosh_sinh():
576 struct cl_cosh_sinh_t {
577         cl_R cosh;
578         cl_R sinh;
579 // Constructor:
580         cl_cosh_sinh_t (const cl_R& u, const cl_R& v) : cosh (u), sinh (v) {}
581 };
582
583 // cl_cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
584 extern const cl_cosh_sinh_t cl_cosh_sinh (const cl_F& x);
585
586 // tanh(x) liefert zu einem Float x die Zahl tanh(x).
587 extern const cl_F tanh (const cl_F& x);
588
589
590 // cl_eulerconst(y) liefert die Eulersche Konstante
591 // im selben Float-Format wie y.
592 // > y: ein Float
593 extern const cl_F cl_eulerconst (const cl_F& y);
594
595 // cl_eulerconst(y) liefert die Eulersche Konstante im Float-Format f.
596 // > f: eine Float-Format-Spezifikation
597 extern const cl_F cl_eulerconst (cl_float_format_t f);
598
599 // cl_eulerconst() liefert die Eulersche Konstante im Default-Float-Format.
600 extern const cl_F cl_eulerconst (void);
601
602 //CL_REQUIRE(cl_F_eulerconst_var)
603
604
605 // cl_catalanconst(y) liefert die Catalansche Konstante
606 // im selben Float-Format wie y.
607 // > y: ein Float
608 extern const cl_F cl_catalanconst (const cl_F& y);
609
610 // cl_catalanconst(y) liefert die Catalansche Konstante im Float-Format f.
611 // > f: eine Float-Format-Spezifikation
612 extern const cl_F cl_catalanconst (cl_float_format_t f);
613
614 // cl_catalanconst() liefert die Catalansche Konstante im Default-Float-Format.
615 extern const cl_F cl_catalanconst (void);
616
617 //CL_REQUIRE(cl_F_catalanconst_var)
618
619
620 // zeta(s) returns the Riemann zeta function at s>1.
621 extern const cl_F cl_zeta (int s, const cl_F& y);
622 extern const cl_F cl_zeta (int s, cl_float_format_t f);
623 extern const cl_F cl_zeta (int s);
624
625
626 // random_F(randomstate,n) liefert zu einem Float n>0 ein zufälliges
627 // Float x mit 0 <= x < n.
628 // > randomstate: ein Random-State, wird verändert
629 extern const cl_F random_F (cl_random_state& randomstate, const cl_F& n);
630
631 inline const cl_F random_F (const cl_F& n)
632         { return random_F(cl_default_random_state,n); }
633
634
635 #ifdef WANT_OBFUSCATING_OPERATORS
636 // This could be optimized to use in-place operations.
637 inline cl_F& operator+= (cl_F& x, const cl_F& y) { return x = x + y; }
638 inline cl_F& operator++ /* prefix */ (cl_F& x) { return x = plus1(x); }
639 inline void operator++ /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = plus1(x); }
640 inline cl_F& operator-= (cl_F& x, const cl_F& y) { return x = x - y; }
641 inline cl_F& operator-- /* prefix */ (cl_F& x) { return x = minus1(x); }
642 inline void operator-- /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = minus1(x); }
643 inline cl_F& operator*= (cl_F& x, const cl_F& y) { return x = x * y; }
644 inline cl_F& operator/= (cl_F& x, const cl_F& y) { return x = x / y; }
645 #endif
646
647
648 CL_REQUIRE(cl_ieee)
649
650
651 // If this is true, floating point underflow returns zero instead of an error.
652 extern cl_boolean cl_inhibit_floating_point_underflow;
653
654
655 #endif /* _CL_FLOAT_H */