]> www.ginac.de Git - cln.git/blob - include/cln/real.h
* All Files have been modified for inclusion of namespace cln;
[cln.git] / include / cln / real.h
1 // Public real number operations.
2
3 #ifndef _CL_REAL_H
4 #define _CL_REAL_H
5
6 #include "cln/number.h"
7 #include "cln/real_class.h"
8 #include "cln/rational_class.h"
9 #include "cln/integer_class.h"
10 #include "cln/float.h"
11 #include "cln/floatformat.h"
12 #include "cln/random.h"
13
14 namespace cln {
15
16 CL_DEFINE_AS_CONVERSION(cl_R)
17
18
19 // zerop(x) testet, ob (= x 0).
20 extern cl_boolean zerop (const cl_R& x);
21
22 // minusp(x) testet, ob (< x 0).
23 extern cl_boolean minusp (const cl_R& x);
24
25 // plusp(x) testet, ob (> x 0).
26 extern cl_boolean plusp (const cl_R& x);
27
28
29 // R_to_SF(x) wandelt eine reelle Zahl x in ein Short-Float um.
30 // < ergebnis: (coerce x 'short-float)
31 extern const cl_SF cl_R_to_SF (const cl_R& x);
32
33 // R_to_FF(x) wandelt eine reelle Zahl x in ein Single-Float um.
34 // < ergebnis: (coerce x 'single-float)
35 extern const cl_FF cl_R_to_FF (const cl_R& x);
36
37 // R_to_DF(x) wandelt eine reelle Zahl x in ein Double-Float um.
38 // < ergebnis: (coerce x 'double-float)
39 extern const cl_DF cl_R_to_DF (const cl_R& x);
40
41 // R_to_LF(x,len) wandelt eine reelle Zahl x in ein Long-Float mit len Digits um.
42 // > uintC len: gewünschte Anzahl Digits, >=LF_minlen
43 // < ergebnis: (coerce x `(long-float ,len))
44 extern const cl_LF cl_R_to_LF (const cl_R& x, uintC len);
45
46 // cl_float(x,y) wandelt eine reelle Zahl x in das Float-Format des
47 // Floats y um und rundet dabei nötigenfalls.
48 // > x: eine reelle Zahl
49 // > y: ein Float
50 // < ergebnis: (float x y)
51 extern const cl_F cl_float (const cl_R& x, const cl_F& y);
52
53 // cl_float(x,f) wandelt eine reelle Zahl x in das Float-Format f um
54 // und rundet dabei nötigenfalls.
55 // > x: eine reelle Zahl
56 // > f: eine Float-Format-Spezifikation
57 // < ergebnis: (float x f)
58 extern const cl_F cl_float (const cl_R& x, float_format_t f);
59
60 // cl_float(x) wandelt eine reelle Zahl x in ein Float um
61 // und rundet dabei nötigenfalls.
62 // > x: eine reelle Zahl
63 // < ergebnis: (float x)
64 // Abhängig von default_float_format.
65 extern const cl_F cl_float (const cl_R& x);
66
67
68 // Liefert (- x), wo x eine reelle Zahl ist.
69 extern const cl_R operator- (const cl_R& x);
70
71 // Liefert (+ x y), wo x und y reelle Zahlen sind.
72 extern const cl_R operator+ (const cl_R& x, const cl_R& y);
73 // Spezialfall: x oder y Float -> Ergebnis Float
74 inline const cl_F operator+ (const cl_R& x, const cl_F& y)
75         { return The(cl_F)(x + The(cl_R)(y)); }
76 inline const cl_F operator+ (const cl_F& x, const cl_R& y)
77         { return The(cl_F)(The(cl_R)(x) + y); }
78 // Dem C++-Compiler muß man nun auch das Folgende sagen:
79 inline const cl_R operator+ (const int x, const cl_R& y)
80         { return cl_I(x) + y; }
81 inline const cl_R operator+ (const unsigned int x, const cl_R& y)
82         { return cl_I(x) + y; }
83 inline const cl_R operator+ (const long x, const cl_R& y)
84         { return cl_I(x) + y; }
85 inline const cl_R operator+ (const unsigned long x, const cl_R& y)
86         { return cl_I(x) + y; }
87 inline const cl_R operator+ (const cl_R& x, const int y)
88         { return x + cl_I(y); }
89 inline const cl_R operator+ (const cl_R& x, const unsigned int y)
90         { return x + cl_I(y); }
91 inline const cl_R operator+ (const cl_R& x, const long y)
92         { return x + cl_I(y); }
93 inline const cl_R operator+ (const cl_R& x, const unsigned long y)
94         { return x + cl_I(y); }
95
96 // Liefert (- x y), wo x und y reelle Zahlen sind.
97 extern const cl_R operator- (const cl_R& x, const cl_R& y);
98 // Spezialfall: x oder y Float -> Ergebnis Float
99 inline const cl_F operator- (const cl_R& x, const cl_F& y)
100         { return The(cl_F)(x - The(cl_R)(y)); }
101 inline const cl_F operator- (const cl_F& x, const cl_R& y)
102         { return The(cl_F)(The(cl_R)(x) - y); }
103 // Dem C++-Compiler muß man nun auch das Folgende sagen:
104 inline const cl_R operator- (const int x, const cl_R& y)
105         { return cl_I(x) - y; }
106 inline const cl_R operator- (const unsigned int x, const cl_R& y)
107         { return cl_I(x) - y; }
108 inline const cl_R operator- (const long x, const cl_R& y)
109         { return cl_I(x) - y; }
110 inline const cl_R operator- (const unsigned long x, const cl_R& y)
111         { return cl_I(x) - y; }
112 inline const cl_R operator- (const cl_R& x, const int y)
113         { return x - cl_I(y); }
114 inline const cl_R operator- (const cl_R& x, const unsigned int y)
115         { return x - cl_I(y); }
116 inline const cl_R operator- (const cl_R& x, const long y)
117         { return x - cl_I(y); }
118 inline const cl_R operator- (const cl_R& x, const unsigned long y)
119         { return x - cl_I(y); }
120
121 // Liefert (* x y), wo x und y reelle Zahlen sind.
122 extern const cl_R operator* (const cl_R& x, const cl_R& y);
123 // Dem C++-Compiler muß man auch das Folgende sagen (wg. `int * cl_F' u.ä.):
124 inline const cl_R operator* (const int x, const cl_R& y)
125         { return cl_I(x) * y; }
126 inline const cl_R operator* (const unsigned int x, const cl_R& y)
127         { return cl_I(x) * y; }
128 inline const cl_R operator* (const long x, const cl_R& y)
129         { return cl_I(x) * y; }
130 inline const cl_R operator* (const unsigned long x, const cl_R& y)
131         { return cl_I(x) * y; }
132 inline const cl_R operator* (const cl_R& x, const int y)
133         { return x * cl_I(y); }
134 inline const cl_R operator* (const cl_R& x, const unsigned int y)
135         { return x * cl_I(y); }
136 inline const cl_R operator* (const cl_R& x, const long y)
137         { return x * cl_I(y); }
138 inline const cl_R operator* (const cl_R& x, const unsigned long y)
139         { return x * cl_I(y); }
140
141 // Liefert (* x x), wo x eine reelle Zahl ist.
142 extern const cl_R square (const cl_R& x);
143
144 // Liefert (/ x y), wo x und y reelle Zahlen sind.
145 extern const cl_R operator/ (const cl_R& x, const cl_R& y);
146 // Spezialfall: x oder y Float -> Ergebnis Float
147 inline const cl_F operator/ (const cl_F& x, const cl_R& y)
148         { return The(cl_F)(The(cl_R)(x) / y); }
149 // Dem C++-Compiler muß man auch das Folgende sagen (wg. `int / cl_F' u.ä.):
150 inline const cl_R operator/ (const int x, const cl_R& y)
151         { return cl_I(x) / y; }
152 inline const cl_R operator/ (const unsigned int x, const cl_R& y)
153         { return cl_I(x) / y; }
154 inline const cl_R operator/ (const long x, const cl_R& y)
155         { return cl_I(x) / y; }
156 inline const cl_R operator/ (const unsigned long x, const cl_R& y)
157         { return cl_I(x) / y; }
158 inline const cl_R operator/ (const cl_R& x, const int y)
159         { return x / cl_I(y); }
160 inline const cl_R operator/ (const cl_R& x, const unsigned int y)
161         { return x / cl_I(y); }
162 inline const cl_R operator/ (const cl_R& x, const long y)
163         { return x / cl_I(y); }
164 inline const cl_R operator/ (const cl_R& x, const unsigned long y)
165         { return x / cl_I(y); }
166
167 // Liefert (abs x), wo x eine reelle Zahl ist.
168 extern const cl_R abs (const cl_R& x);
169
170 // recip(x) liefert (/ x), wo x eine reelle Zahl ist.
171 extern const cl_R recip (const cl_R& x);
172
173 // (1+ x), wo x eine reelle Zahl ist.
174 extern const cl_R plus1 (const cl_R& x);
175
176 // (1- x), wo x eine reelle Zahl ist.
177 extern const cl_R minus1 (const cl_R& x);
178
179
180 // Return type for rounding operators.
181 // x / y  --> (q,r) with x = y*q+r.
182 struct cl_R_div_t {
183         cl_I quotient;
184         cl_R remainder;
185 // Constructor.
186         cl_R_div_t () {}
187         cl_R_div_t (const cl_I& q, const cl_R& r) : quotient(q), remainder(r) {}
188         cl_R_div_t (const struct cl_I_div_t &);
189         cl_R_div_t (const struct cl_RA_div_t &);
190         cl_R_div_t (const struct cl_F_div_t &);
191 };
192
193 // floor2(x) liefert (floor x), wo x eine reelle Zahl ist.
194 extern const cl_R_div_t floor2 (const cl_R& x);
195 extern const cl_I floor1 (const cl_R& x);
196
197 // ceiling2(x) liefert (ceiling x), wo x eine reelle Zahl ist.
198 extern const cl_R_div_t ceiling2 (const cl_R& x);
199 extern const cl_I ceiling1 (const cl_R& x);
200
201 // truncate2(x) liefert (truncate x), wo x eine reelle Zahl ist.
202 extern const cl_R_div_t truncate2 (const cl_R& x);
203 extern const cl_I truncate1 (const cl_R& x);
204
205 // round2(x) liefert (round x), wo x eine reelle Zahl ist.
206 extern const cl_R_div_t round2 (const cl_R& x);
207 extern const cl_I round1 (const cl_R& x);
208
209 // floor2(x,y) liefert (floor x y), wo x und y reelle Zahlen sind.
210 extern const cl_R_div_t floor2 (const cl_R& x, const cl_R& y);
211 extern const cl_I floor1 (const cl_R& x, const cl_R& y);
212
213 // ceiling2(x,y) liefert (ceiling x y), wo x und y reelle Zahlen sind.
214 extern const cl_R_div_t ceiling2 (const cl_R& x, const cl_R& y);
215 extern const cl_I ceiling1 (const cl_R& x, const cl_R& y);
216
217 // truncate2(x,y) liefert (truncate x y), wo x und y reelle Zahlen sind.
218 extern const cl_R_div_t truncate2 (const cl_R& x, const cl_R& y);
219 extern const cl_I truncate1 (const cl_R& x, const cl_R& y);
220
221 // round2(x,y) liefert (round x y), wo x und y reelle Zahlen sind.
222 extern const cl_R_div_t round2 (const cl_R& x, const cl_R& y);
223 extern const cl_I round1 (const cl_R& x, const cl_R& y);
224
225
226 // Return type for frounding operators.
227 // x / y  --> (q,r) with x = y*q+r.
228 struct cl_R_fdiv_t {
229         cl_F quotient;
230         cl_R remainder;
231 // Constructor.
232         cl_R_fdiv_t () {}
233         cl_R_fdiv_t (const cl_F& q, const cl_R& r) : quotient(q), remainder(r) {}
234         cl_R_fdiv_t (const struct cl_F_fdiv_t &);
235 };
236
237 // ffloor2(x) liefert (ffloor x), wo x eine reelle Zahl ist.
238 extern const cl_R_fdiv_t ffloor2 (const cl_R& x);
239 extern const cl_F ffloor (const cl_R& x);
240
241 // fceiling2(x) liefert (fceiling x), wo x eine reelle Zahl ist.
242 extern const cl_R_fdiv_t fceiling2 (const cl_R& x);
243 extern const cl_F fceiling (const cl_R& x);
244
245 // ftruncate2(x) liefert (ftruncate x), wo x eine reelle Zahl ist.
246 extern const cl_R_fdiv_t ftruncate2 (const cl_R& x);
247 extern const cl_F ftruncate (const cl_R& x);
248
249 // fround2(x) liefert (fround x), wo x eine reelle Zahl ist.
250 extern const cl_R_fdiv_t fround2 (const cl_R& x);
251 extern const cl_F fround (const cl_R& x);
252
253 // ffloor2(x,y) liefert (ffloor x y), wo x und y reelle Zahlen sind.
254 extern const cl_R_fdiv_t ffloor2 (const cl_R& x, const cl_R& y);
255 extern const cl_F ffloor (const cl_R& x, const cl_R& y);
256
257 // fceiling2(x,y) liefert (fceiling x y), wo x und y reelle Zahlen sind.
258 extern const cl_R_fdiv_t fceiling2 (const cl_R& x, const cl_R& y);
259 extern const cl_F fceiling (const cl_R& x, const cl_R& y);
260
261 // ftruncate2(x,y) liefert (ftruncate x y), wo x und y reelle Zahlen sind.
262 extern const cl_R_fdiv_t ftruncate2 (const cl_R& x, const cl_R& y);
263 extern const cl_F ftruncate (const cl_R& x, const cl_R& y);
264
265 // fround2(x,y) liefert (fround x y), wo x und y reelle Zahlen sind.
266 extern const cl_R_fdiv_t fround2 (const cl_R& x, const cl_R& y);
267 extern const cl_F fround (const cl_R& x, const cl_R& y);
268
269
270 // mod(x,y) = (mod x y), wo x und y reelle Zahlen sind.
271 extern const cl_R mod (const cl_R& x, const cl_R& y);
272
273 // rem(x,y) = (rem x y), wo x und y reelle Zahlen sind.
274 extern const cl_R rem (const cl_R& x, const cl_R& y);
275
276
277 // rational(x) liefert (rational x), wo x eine reelle Zahl ist.
278 extern const cl_RA rational (const cl_R& x);
279 // Spezialfall:
280 inline const cl_RA rational (const cl_RA& x) { return x; }
281
282
283 // equal(x,y) vergleicht zwei reelle Zahlen x und y auf Gleichheit.
284 extern cl_boolean equal (const cl_R& x, const cl_R& y);
285 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
286 extern uint32 equal_hashcode (const cl_R& x);
287
288 // compare(x,y) vergleicht zwei reelle Zahlen x und y.
289 // Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
290 extern cl_signean compare (const cl_R& x, const cl_R& y);
291
292 inline bool operator== (const cl_R& x, const cl_R& y)
293         { return equal(x,y); }
294 inline bool operator!= (const cl_R& x, const cl_R& y)
295         { return !equal(x,y); }
296 inline bool operator<= (const cl_R& x, const cl_R& y)
297         { return compare(x,y)<=0; }
298 inline bool operator< (const cl_R& x, const cl_R& y)
299         { return compare(x,y)<0; }
300 inline bool operator>= (const cl_R& x, const cl_R& y)
301         { return compare(x,y)>=0; }
302 inline bool operator> (const cl_R& x, const cl_R& y)
303         { return compare(x,y)>0; }
304
305 // max(x,y) liefert (max x y), wo x und y reelle Zahlen sind.
306 extern const cl_R max (const cl_R& x, const cl_R& y);
307
308 // min(x,y) liefert (min x y), wo x und y reelle Zahlen sind.
309 extern const cl_R min (const cl_R& x, const cl_R& y);
310
311 // signum(x) liefert (signum x), wo x eine reelle Zahl ist.
312 extern const cl_R signum (const cl_R& x);
313
314 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer reellen Zahl x >=0.
315 extern const cl_R sqrt (const cl_R& x);
316 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer rationalen Zahl x >=0.
317 extern const cl_R sqrt (const cl_RA& x);
318
319 // (expt x y), wo x eine reelle Zahl und y ein Integer ist.
320 extern const cl_R expt (const cl_R& x, sintL y);
321 extern const cl_R expt (const cl_R& x, const cl_I& y);
322
323 // rationalize(x) liefert (rationalize x), wo x eine reelle Zahl ist.
324 extern const cl_RA rationalize (const cl_R& x);
325
326
327 // Konversion zu einem C "float".
328 extern float float_approx (const cl_R& x);
329
330 // Konversion zu einem C "double".
331 extern double double_approx (const cl_R& x);
332
333
334 // Transcendental functions
335
336
337 // atan(x,y) liefert zu zwei reellen Zahlen x, y den Winkel von (x,y)
338 // in Polarkoordinaten. Ergebnis rational nur, wenn x>0 und y=0.
339 extern const cl_R atan (const cl_R& x, const cl_R& y);
340 // Spezialfall: y Float -> Ergebnis Float
341 inline const cl_F atan (const cl_R& x, const cl_F& y)
342         { return The(cl_F)(atan(x,The(cl_R)(y))); }
343 // Dem C++-Compiler muß man nun auch das Folgende sagen:
344 inline const cl_R atan (const cl_R& x, const int y)
345         { return atan(x,cl_I(y)); }
346 inline const cl_R atan (const cl_R& x, const unsigned int y)
347         { return atan(x,cl_I(y)); }
348 inline const cl_R atan (const cl_R& x, const long y)
349         { return atan(x,cl_I(y)); }
350 inline const cl_R atan (const cl_R& x, const unsigned long y)
351         { return atan(x,cl_I(y)); }
352
353 // atan(x) liefert den Arctan einer reellen Zahl x.
354 // Ergebnis rational nur, wenn x=0.
355 extern const cl_R atan (const cl_R& x);
356 // Spezialfall: x Float -> Ergebnis Float
357 inline const cl_F atan (const cl_F& x) { return The(cl_F)(atan(The(cl_R)(x))); }
358 // Dem C++-Compiler muß man nun auch das Folgende sagen:
359 inline const cl_R atan (const int x) { return atan(cl_I(x)); }
360 inline const cl_R atan (const unsigned int x) { return atan(cl_I(x)); }
361 inline const cl_R atan (const long x) { return atan(cl_I(x)); }
362 inline const cl_R atan (const unsigned long x) { return atan(cl_I(x)); }
363
364 // sin(x) liefert den Sinus (sin x) einer reellen Zahl x.
365 extern const cl_R sin (const cl_R& x);
366 // Dem C++-Compiler muß man nun auch das Folgende sagen:
367 inline const cl_R sin (const int x) { return sin(cl_I(x)); }
368 inline const cl_R sin (const unsigned int x) { return sin(cl_I(x)); }
369 inline const cl_R sin (const long x) { return sin(cl_I(x)); }
370 inline const cl_R sin (const unsigned long x) { return sin(cl_I(x)); }
371
372 // cos(x) liefert den Cosinus (cos x) einer reellen Zahl x.
373 extern const cl_R cos (const cl_R& x);
374 // Dem C++-Compiler muß man nun auch das Folgende sagen:
375 inline const cl_R cos (const int x) { return cos(cl_I(x)); }
376 inline const cl_R cos (const unsigned int x) { return cos(cl_I(x)); }
377 inline const cl_R cos (const long x) { return cos(cl_I(x)); }
378 inline const cl_R cos (const unsigned long x) { return cos(cl_I(x)); }
379
380 // cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
381 extern const cos_sin_t cos_sin (const cl_R& x);
382
383 // tan(x) liefert den Tangens (tan x) einer reellen Zahl x.
384 extern const cl_R tan (const cl_R& x);
385 // Dem C++-Compiler muß man nun auch das Folgende sagen:
386 inline const cl_R tan (const int x) { return tan(cl_I(x)); }
387 inline const cl_R tan (const unsigned int x) { return tan(cl_I(x)); }
388 inline const cl_R tan (const long x) { return tan(cl_I(x)); }
389 inline const cl_R tan (const unsigned long x) { return tan(cl_I(x)); }
390
391 // ln(x) liefert zu einer reellen Zahl x>0 die Zahl ln(x).
392 extern const cl_R ln (const cl_R& x);
393 // Dem C++-Compiler muß man nun auch das Folgende sagen:
394 inline const cl_R ln (const int x) { return ln(cl_I(x)); }
395 inline const cl_R ln (const unsigned int x) { return ln(cl_I(x)); }
396 inline const cl_R ln (const long x) { return ln(cl_I(x)); }
397 inline const cl_R ln (const unsigned long x) { return ln(cl_I(x)); }
398
399 // log(a,b) liefert zu reellen Zahlen a>0, b>0 die Zahl
400 // log(a,b)=ln(a)/ln(b).
401 // Ergebnis rational nur, wenn a=1 oder a und b rational.
402 extern const cl_R log (const cl_R& a, const cl_R& b);
403
404 // exp(x) liefert zu einer reellen Zahl x die Zahl exp(x).
405 extern const cl_R exp (const cl_R& x);
406 // Dem C++-Compiler muß man nun auch das Folgende sagen:
407 inline const cl_R exp (const int x) { return exp(cl_I(x)); }
408 inline const cl_R exp (const unsigned int x) { return exp(cl_I(x)); }
409 inline const cl_R exp (const long x) { return exp(cl_I(x)); }
410 inline const cl_R exp (const unsigned long x) { return exp(cl_I(x)); }
411
412 // sinh(x) liefert zu einer reellen Zahl x die Zahl sinh(x).
413 extern const cl_R sinh (const cl_R& x);
414 // Dem C++-Compiler muß man nun auch das Folgende sagen:
415 inline const cl_R sinh (const int x) { return sinh(cl_I(x)); }
416 inline const cl_R sinh (const unsigned int x) { return sinh(cl_I(x)); }
417 inline const cl_R sinh (const long x) { return sinh(cl_I(x)); }
418 inline const cl_R sinh (const unsigned long x) { return sinh(cl_I(x)); }
419
420 // cosh(x) liefert zu einer reellen Zahl x die Zahl cosh(x).
421 extern const cl_R cosh (const cl_R& x);
422 // Dem C++-Compiler muß man nun auch das Folgende sagen:
423 inline const cl_R cosh (const int x) { return cosh(cl_I(x)); }
424 inline const cl_R cosh (const unsigned int x) { return cosh(cl_I(x)); }
425 inline const cl_R cosh (const long x) { return cosh(cl_I(x)); }
426 inline const cl_R cosh (const unsigned long x) { return cosh(cl_I(x)); }
427
428 // cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
429 extern const cosh_sinh_t cosh_sinh (const cl_R& x);
430
431 // tanh(x) liefert zu einer reellen Zahl x die Zahl tanh(x).
432 extern const cl_R tanh (const cl_R& x);
433 // Dem C++-Compiler muß man nun auch das Folgende sagen:
434 inline const cl_R tanh (const int x) { return tanh(cl_I(x)); }
435 inline const cl_R tanh (const unsigned int x) { return tanh(cl_I(x)); }
436 inline const cl_R tanh (const long x) { return tanh(cl_I(x)); }
437 inline const cl_R tanh (const unsigned long x) { return tanh(cl_I(x)); }
438
439
440 // random_R(randomstate,n) liefert zu einer reellen Zahl n>0 eine Zufallszahl
441 // x mit 0 <= x < n.
442 extern const cl_R random_R (random_state& randomstate, const cl_R& n);
443
444 inline const cl_R random_R (const cl_R& n)
445         { return random_R(default_random_state,n); }
446
447
448 #ifdef WANT_OBFUSCATING_OPERATORS
449 // This could be optimized to use in-place operations.
450 inline cl_R& operator+= (cl_R& x, const cl_R& y) { return x = x + y; }
451 inline cl_F& operator+= (cl_F& x, const cl_R& y) { return x = x + y; }
452 inline cl_F& operator+= (cl_F& x, const cl_RA& y) { return x = x + y; }
453 inline cl_F& operator+= (cl_F& x, const cl_I& y) { return x = x + y; }
454 inline cl_R& operator+= (cl_R& x, const int y) { return x = x + y; }
455 inline cl_R& operator+= (cl_R& x, const unsigned int y) { return x = x + y; }
456 inline cl_R& operator+= (cl_R& x, const long y) { return x = x + y; }
457 inline cl_R& operator+= (cl_R& x, const unsigned long y) { return x = x + y; }
458 inline cl_F& operator+= (cl_F& x, const int y) { return x = x + y; }
459 inline cl_F& operator+= (cl_F& x, const unsigned int y) { return x = x + y; }
460 inline cl_F& operator+= (cl_F& x, const long y) { return x = x + y; }
461 inline cl_F& operator+= (cl_F& x, const unsigned long y) { return x = x + y; }
462 inline cl_R& operator++ /* prefix */ (cl_R& x) { return x = plus1(x); }
463 inline void operator++ /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = plus1(x); }
464 inline cl_R& operator-= (cl_R& x, const cl_R& y) { return x = x - y; }
465 inline cl_F& operator-= (cl_F& x, const cl_R& y) { return x = x - y; }
466 inline cl_F& operator-= (cl_F& x, const cl_RA& y) { return x = x - y; }
467 inline cl_F& operator-= (cl_F& x, const cl_I& y) { return x = x - y; }
468 inline cl_R& operator-= (cl_R& x, const int y) { return x = x - y; }
469 inline cl_R& operator-= (cl_R& x, const unsigned int y) { return x = x - y; }
470 inline cl_R& operator-= (cl_R& x, const long y) { return x = x - y; }
471 inline cl_R& operator-= (cl_R& x, const unsigned long y) { return x = x - y; }
472 inline cl_F& operator-= (cl_F& x, const int y) { return x = x - y; }
473 inline cl_F& operator-= (cl_F& x, const unsigned int y) { return x = x - y; }
474 inline cl_F& operator-= (cl_F& x, const long y) { return x = x - y; }
475 inline cl_F& operator-= (cl_F& x, const unsigned long y) { return x = x - y; }
476 inline cl_R& operator-- /* prefix */ (cl_R& x) { return x = minus1(x); }
477 inline void operator-- /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = minus1(x); }
478 inline cl_R& operator*= (cl_R& x, const cl_R& y) { return x = x * y; }
479 inline cl_R& operator/= (cl_R& x, const cl_R& y) { return x = x / y; }
480 inline cl_F& operator/= (cl_F& x, const cl_R& y) { return x = x / y; }
481 inline cl_F& operator/= (cl_F& x, const cl_RA& y) { return x = x / y; }
482 inline cl_F& operator/= (cl_F& x, const cl_I& y) { return x = x / y; }
483 inline cl_R& operator/= (cl_R& x, const int y) { return x = x / y; }
484 inline cl_R& operator/= (cl_R& x, const unsigned int y) { return x = x / y; }
485 inline cl_R& operator/= (cl_R& x, const long y) { return x = x / y; }
486 inline cl_R& operator/= (cl_R& x, const unsigned long y) { return x = x / y; }
487 inline cl_F& operator/= (cl_F& x, const int y) { return x = x / y; }
488 inline cl_F& operator/= (cl_F& x, const unsigned int y) { return x = x / y; }
489 inline cl_F& operator/= (cl_F& x, const long y) { return x = x / y; }
490 inline cl_F& operator/= (cl_F& x, const unsigned long y) { return x = x / y; }
491 #endif
492
493
494 // Complex operations, trivial for reals
495
496 inline const cl_R realpart (const cl_R& x)
497 {
498         return x;
499 }
500 inline const cl_R imagpart (const cl_R& x)
501 {
502         (void)x; // unused x
503         return 0;
504 }
505 inline const cl_R conjugate (const cl_R& x)
506 {
507         return x;
508 }
509
510
511 // Debugging support.
512 #ifdef CL_DEBUG
513 extern int cl_R_debug_module;
514 static void* const cl_R_debug_dummy[] = { &cl_R_debug_dummy,
515         &cl_R_debug_module
516 };
517 #endif
518
519 }  // namespace cln
520
521 #endif /* _CL_REAL_H */