Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:32

0001 // Public real number operations.
0002 
0003 #ifndef _CL_REAL_H
0004 #define _CL_REAL_H
0005 
0006 #include "cln/number.h"
0007 #include "cln/real_class.h"
0008 #include "cln/rational_class.h"
0009 #include "cln/integer_class.h"
0010 #include "cln/float.h"
0011 #include "cln/floatformat.h"
0012 #include "cln/random.h"
0013 
0014 namespace cln {
0015 
0016 CL_DEFINE_AS_CONVERSION(cl_R)
0017 
0018 
0019 // zerop(x) testet, ob (= x 0).
0020 extern bool zerop (const cl_R& x);
0021 
0022 // minusp(x) testet, ob (< x 0).
0023 extern bool minusp (const cl_R& x);
0024 
0025 // plusp(x) testet, ob (> x 0).
0026 extern bool plusp (const cl_R& x);
0027 
0028 
0029 // R_to_SF(x) wandelt eine reelle Zahl x in ein Short-Float um.
0030 // < ergebnis: (coerce x 'short-float)
0031 extern const cl_SF cl_R_to_SF (const cl_R& x);
0032 
0033 // R_to_FF(x) wandelt eine reelle Zahl x in ein Single-Float um.
0034 // < ergebnis: (coerce x 'single-float)
0035 extern const cl_FF cl_R_to_FF (const cl_R& x);
0036 
0037 // R_to_DF(x) wandelt eine reelle Zahl x in ein Double-Float um.
0038 // < ergebnis: (coerce x 'double-float)
0039 extern const cl_DF cl_R_to_DF (const cl_R& x);
0040 
0041 // R_to_LF(x,len) wandelt eine reelle Zahl x in ein Long-Float mit len Digits um.
0042 // > uintC len: gewünschte Anzahl Digits, >=LF_minlen
0043 // < ergebnis: (coerce x `(long-float ,len))
0044 extern const cl_LF cl_R_to_LF (const cl_R& x, uintC len);
0045 
0046 // cl_float(x,y) wandelt eine reelle Zahl x in das Float-Format des
0047 // Floats y um und rundet dabei nötigenfalls.
0048 // > x: eine reelle Zahl
0049 // > y: ein Float
0050 // < ergebnis: (float x y)
0051 extern const cl_F cl_float (const cl_R& x, const cl_F& y);
0052 
0053 // cl_float(x,f) wandelt eine reelle Zahl x in das Float-Format f um
0054 // und rundet dabei nötigenfalls.
0055 // > x: eine reelle Zahl
0056 // > f: eine Float-Format-Spezifikation
0057 // < ergebnis: (float x f)
0058 extern const cl_F cl_float (const cl_R& x, float_format_t f);
0059 
0060 // cl_float(x) wandelt eine reelle Zahl x in ein Float um
0061 // und rundet dabei nötigenfalls.
0062 // > x: eine reelle Zahl
0063 // < ergebnis: (float x)
0064 // Abhängig von default_float_format.
0065 extern const cl_F cl_float (const cl_R& x);
0066 
0067 
0068 // Liefert (- x), wo x eine reelle Zahl ist.
0069 extern const cl_R operator- (const cl_R& x);
0070 
0071 // Liefert (+ x y), wo x und y reelle Zahlen sind.
0072 extern const cl_R operator+ (const cl_R& x, const cl_R& y);
0073 // Spezialfall: x oder y Float -> Ergebnis Float
0074 inline const cl_F operator+ (const cl_R& x, const cl_F& y)
0075     { return The(cl_F)(x + The(cl_R)(y)); }
0076 inline const cl_F operator+ (const cl_F& x, const cl_R& y)
0077     { return The(cl_F)(The(cl_R)(x) + y); }
0078 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0079 inline const cl_R operator+ (const int x, const cl_R& y)
0080     { return cl_I(x) + y; }
0081 inline const cl_R operator+ (const unsigned int x, const cl_R& y)
0082     { return cl_I(x) + y; }
0083 inline const cl_R operator+ (const long x, const cl_R& y)
0084     { return cl_I(x) + y; }
0085 inline const cl_R operator+ (const unsigned long x, const cl_R& y)
0086     { return cl_I(x) + y; }
0087 inline const cl_R operator+ (const long long x, const cl_R& y)
0088     { return cl_I(x) + y; }
0089 inline const cl_R operator+ (const unsigned long long x, const cl_R& y)
0090     { return cl_I(x) + y; }
0091 inline const cl_F operator+ (const float x, const cl_R& y)
0092     { return The(cl_F)(cl_R(x) + y); }
0093 inline const cl_F operator+ (const double x, const cl_R& y)
0094     { return The(cl_F)(cl_R(x) + y); }
0095 inline const cl_R operator+ (const cl_R& x, const int y)
0096     { return x + cl_I(y); }
0097 inline const cl_R operator+ (const cl_R& x, const unsigned int y)
0098     { return x + cl_I(y); }
0099 inline const cl_R operator+ (const cl_R& x, const long y)
0100     { return x + cl_I(y); }
0101 inline const cl_R operator+ (const cl_R& x, const unsigned long y)
0102     { return x + cl_I(y); }
0103 inline const cl_R operator+ (const cl_R& x, const long long y)
0104     { return x + cl_I(y); }
0105 inline const cl_R operator+ (const cl_R& x, const unsigned long long y)
0106     { return x + cl_I(y); }
0107 inline const cl_F operator+ (const cl_R& x, const float y)
0108     { return The(cl_F)(x + cl_R(y)); }
0109 inline const cl_F operator+ (const cl_R& x, const double y)
0110     { return The(cl_F)(x + cl_R(y)); }
0111 
0112 // Liefert (- x y), wo x und y reelle Zahlen sind.
0113 extern const cl_R operator- (const cl_R& x, const cl_R& y);
0114 // Spezialfall: x oder y Float -> Ergebnis Float
0115 inline const cl_F operator- (const cl_R& x, const cl_F& y)
0116     { return The(cl_F)(x - The(cl_R)(y)); }
0117 inline const cl_F operator- (const cl_F& x, const cl_R& y)
0118     { return The(cl_F)(The(cl_R)(x) - y); }
0119 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0120 inline const cl_R operator- (const int x, const cl_R& y)
0121     { return cl_I(x) - y; }
0122 inline const cl_R operator- (const unsigned int x, const cl_R& y)
0123     { return cl_I(x) - y; }
0124 inline const cl_R operator- (const long x, const cl_R& y)
0125     { return cl_I(x) - y; }
0126 inline const cl_R operator- (const unsigned long x, const cl_R& y)
0127     { return cl_I(x) - y; }
0128 inline const cl_R operator- (const long long x, const cl_R& y)
0129     { return cl_I(x) - y; }
0130 inline const cl_R operator- (const unsigned long long x, const cl_R& y)
0131     { return cl_I(x) - y; }
0132 inline const cl_F operator- (const float x, const cl_R& y)
0133     { return The(cl_F)(cl_R(x) - y); }
0134 inline const cl_F operator- (const double x, const cl_R& y)
0135     { return The(cl_F)(cl_R(x) - y); }
0136 inline const cl_R operator- (const cl_R& x, const int y)
0137     { return x - cl_I(y); }
0138 inline const cl_R operator- (const cl_R& x, const unsigned int y)
0139     { return x - cl_I(y); }
0140 inline const cl_R operator- (const cl_R& x, const long y)
0141     { return x - cl_I(y); }
0142 inline const cl_R operator- (const cl_R& x, const unsigned long y)
0143     { return x - cl_I(y); }
0144 inline const cl_R operator- (const cl_R& x, const long long y)
0145     { return x - cl_I(y); }
0146 inline const cl_R operator- (const cl_R& x, const unsigned long long y)
0147     { return x - cl_I(y); }
0148 inline const cl_F operator- (const cl_R& x, const float y)
0149     { return The(cl_F)(x - cl_R(y)); }
0150 inline const cl_F operator- (const cl_R& x, const double y)
0151     { return The(cl_F)(x - cl_R(y)); }
0152 
0153 // Liefert (* x y), wo x und y reelle Zahlen sind.
0154 extern const cl_R operator* (const cl_R& x, const cl_R& y);
0155 // Dem C++-Compiler muß man auch das Folgende sagen (wg. `int * cl_F' u.ä.):
0156 inline const cl_R operator* (const int x, const cl_R& y)
0157     { return cl_I(x) * y; }
0158 inline const cl_R operator* (const unsigned int x, const cl_R& y)
0159     { return cl_I(x) * y; }
0160 inline const cl_R operator* (const long x, const cl_R& y)
0161     { return cl_I(x) * y; }
0162 inline const cl_R operator* (const unsigned long x, const cl_R& y)
0163     { return cl_I(x) * y; }
0164 inline const cl_R operator* (const long long x, const cl_R& y)
0165     { return cl_I(x) * y; }
0166 inline const cl_R operator* (const unsigned long long x, const cl_R& y)
0167     { return cl_I(x) * y; }
0168 inline const cl_R operator* (const float x, const cl_R& y)
0169     { return cl_R(x) * y; }
0170 inline const cl_R operator* (const double x, const cl_R& y)
0171     { return cl_R(x) * y; }
0172 inline const cl_R operator* (const cl_R& x, const int y)
0173     { return x * cl_I(y); }
0174 inline const cl_R operator* (const cl_R& x, const unsigned int y)
0175     { return x * cl_I(y); }
0176 inline const cl_R operator* (const cl_R& x, const long y)
0177     { return x * cl_I(y); }
0178 inline const cl_R operator* (const cl_R& x, const unsigned long y)
0179     { return x * cl_I(y); }
0180 inline const cl_R operator* (const cl_R& x, const long long y)
0181     { return x * cl_I(y); }
0182 inline const cl_R operator* (const cl_R& x, const unsigned long long y)
0183     { return x * cl_I(y); }
0184 inline const cl_R operator* (const cl_R& x, const float y)
0185     { return x * cl_R(y); }
0186 inline const cl_R operator* (const cl_R& x, const double y)
0187     { return x * cl_R(y); }
0188 
0189 // Liefert (* x x), wo x eine reelle Zahl ist.
0190 extern const cl_R square (const cl_R& x);
0191 
0192 // Liefert (/ x y), wo x und y reelle Zahlen sind.
0193 extern const cl_R operator/ (const cl_R& x, const cl_R& y);
0194 // Spezialfall: x Float -> Ergebnis Float
0195 inline const cl_F operator/ (const cl_F& x, const cl_R& y)
0196     { return The(cl_F)(The(cl_R)(x) / y); }
0197 // Dem C++-Compiler muß man auch das Folgende sagen (wg. `int / cl_F' u.ä.):
0198 inline const cl_R operator/ (const int x, const cl_R& y)
0199     { return cl_I(x) / y; }
0200 inline const cl_R operator/ (const unsigned int x, const cl_R& y)
0201     { return cl_I(x) / y; }
0202 inline const cl_R operator/ (const long x, const cl_R& y)
0203     { return cl_I(x) / y; }
0204 inline const cl_R operator/ (const unsigned long x, const cl_R& y)
0205     { return cl_I(x) / y; }
0206 inline const cl_R operator/ (const long long x, const cl_R& y)
0207     { return cl_I(x) / y; }
0208 inline const cl_R operator/ (const unsigned long long x, const cl_R& y)
0209     { return cl_I(x) / y; }
0210 inline const cl_F operator/ (const float x, const cl_R& y)
0211     { return The(cl_F)(cl_R(x) / y); }
0212 inline const cl_F operator/ (const double x, const cl_R& y)
0213     { return The(cl_F)(cl_R(x) / y); }
0214 inline const cl_R operator/ (const cl_R& x, const int y)
0215     { return x / cl_I(y); }
0216 inline const cl_R operator/ (const cl_R& x, const unsigned int y)
0217     { return x / cl_I(y); }
0218 inline const cl_R operator/ (const cl_R& x, const long y)
0219     { return x / cl_I(y); }
0220 inline const cl_R operator/ (const cl_R& x, const unsigned long y)
0221     { return x / cl_I(y); }
0222 inline const cl_R operator/ (const cl_R& x, const long long y)
0223     { return x / cl_I(y); }
0224 inline const cl_R operator/ (const cl_R& x, const unsigned long long y)
0225     { return x / cl_I(y); }
0226 inline const cl_R operator/ (const cl_R& x, const float y)
0227     { return x / cl_R(y); }
0228 inline const cl_R operator/ (const cl_R& x, const double y)
0229     { return x / cl_R(y); }
0230 
0231 // Liefert (abs x), wo x eine reelle Zahl ist.
0232 extern const cl_R abs (const cl_R& x);
0233 
0234 // recip(x) liefert (/ x), wo x eine reelle Zahl ist.
0235 extern const cl_R recip (const cl_R& x);
0236 
0237 // (1+ x), wo x eine reelle Zahl ist.
0238 extern const cl_R plus1 (const cl_R& x);
0239 
0240 // (1- x), wo x eine reelle Zahl ist.
0241 extern const cl_R minus1 (const cl_R& x);
0242 
0243 
0244 // Return type for rounding operators.
0245 // x / y  --> (q,r) with x = y*q+r.
0246 struct cl_R_div_t {
0247     cl_I quotient;
0248     cl_R remainder;
0249 // Constructor.
0250     cl_R_div_t () {}
0251     cl_R_div_t (const cl_I& q, const cl_R& r) : quotient(q), remainder(r) {}
0252     cl_R_div_t (const struct cl_I_div_t &);
0253     cl_R_div_t (const struct cl_RA_div_t &);
0254     cl_R_div_t (const struct cl_F_div_t &);
0255 };
0256 
0257 // floor2(x) liefert (floor x), wo x eine reelle Zahl ist.
0258 extern const cl_R_div_t floor2 (const cl_R& x);
0259 extern const cl_I floor1 (const cl_R& x);
0260 
0261 // ceiling2(x) liefert (ceiling x), wo x eine reelle Zahl ist.
0262 extern const cl_R_div_t ceiling2 (const cl_R& x);
0263 extern const cl_I ceiling1 (const cl_R& x);
0264 
0265 // truncate2(x) liefert (truncate x), wo x eine reelle Zahl ist.
0266 extern const cl_R_div_t truncate2 (const cl_R& x);
0267 extern const cl_I truncate1 (const cl_R& x);
0268 
0269 // round2(x) liefert (round x), wo x eine reelle Zahl ist.
0270 extern const cl_R_div_t round2 (const cl_R& x);
0271 extern const cl_I round1 (const cl_R& x);
0272 
0273 // floor2(x,y) liefert (floor x y), wo x und y reelle Zahlen sind.
0274 extern const cl_R_div_t floor2 (const cl_R& x, const cl_R& y);
0275 extern const cl_I floor1 (const cl_R& x, const cl_R& y);
0276 
0277 // ceiling2(x,y) liefert (ceiling x y), wo x und y reelle Zahlen sind.
0278 extern const cl_R_div_t ceiling2 (const cl_R& x, const cl_R& y);
0279 extern const cl_I ceiling1 (const cl_R& x, const cl_R& y);
0280 
0281 // truncate2(x,y) liefert (truncate x y), wo x und y reelle Zahlen sind.
0282 extern const cl_R_div_t truncate2 (const cl_R& x, const cl_R& y);
0283 extern const cl_I truncate1 (const cl_R& x, const cl_R& y);
0284 
0285 // round2(x,y) liefert (round x y), wo x und y reelle Zahlen sind.
0286 extern const cl_R_div_t round2 (const cl_R& x, const cl_R& y);
0287 extern const cl_I round1 (const cl_R& x, const cl_R& y);
0288 
0289 
0290 // Return type for frounding operators.
0291 // x / y  --> (q,r) with x = y*q+r.
0292 struct cl_R_fdiv_t {
0293     cl_F quotient;
0294     cl_R remainder;
0295 // Constructor.
0296     cl_R_fdiv_t () {}
0297     cl_R_fdiv_t (const cl_F& q, const cl_R& r) : quotient(q), remainder(r) {}
0298     cl_R_fdiv_t (const struct cl_F_fdiv_t &);
0299 };
0300 
0301 // ffloor2(x) liefert (ffloor x), wo x eine reelle Zahl ist.
0302 extern const cl_R_fdiv_t ffloor2 (const cl_R& x);
0303 extern const cl_F ffloor (const cl_R& x);
0304 
0305 // fceiling2(x) liefert (fceiling x), wo x eine reelle Zahl ist.
0306 extern const cl_R_fdiv_t fceiling2 (const cl_R& x);
0307 extern const cl_F fceiling (const cl_R& x);
0308 
0309 // ftruncate2(x) liefert (ftruncate x), wo x eine reelle Zahl ist.
0310 extern const cl_R_fdiv_t ftruncate2 (const cl_R& x);
0311 extern const cl_F ftruncate (const cl_R& x);
0312 
0313 // fround2(x) liefert (fround x), wo x eine reelle Zahl ist.
0314 extern const cl_R_fdiv_t fround2 (const cl_R& x);
0315 extern const cl_F fround (const cl_R& x);
0316 
0317 // ffloor2(x,y) liefert (ffloor x y), wo x und y reelle Zahlen sind.
0318 extern const cl_R_fdiv_t ffloor2 (const cl_R& x, const cl_R& y);
0319 extern const cl_F ffloor (const cl_R& x, const cl_R& y);
0320 
0321 // fceiling2(x,y) liefert (fceiling x y), wo x und y reelle Zahlen sind.
0322 extern const cl_R_fdiv_t fceiling2 (const cl_R& x, const cl_R& y);
0323 extern const cl_F fceiling (const cl_R& x, const cl_R& y);
0324 
0325 // ftruncate2(x,y) liefert (ftruncate x y), wo x und y reelle Zahlen sind.
0326 extern const cl_R_fdiv_t ftruncate2 (const cl_R& x, const cl_R& y);
0327 extern const cl_F ftruncate (const cl_R& x, const cl_R& y);
0328 
0329 // fround2(x,y) liefert (fround x y), wo x und y reelle Zahlen sind.
0330 extern const cl_R_fdiv_t fround2 (const cl_R& x, const cl_R& y);
0331 extern const cl_F fround (const cl_R& x, const cl_R& y);
0332 
0333 
0334 // mod(x,y) = (mod x y), wo x und y reelle Zahlen sind.
0335 extern const cl_R mod (const cl_R& x, const cl_R& y);
0336 
0337 // rem(x,y) = (rem x y), wo x und y reelle Zahlen sind.
0338 extern const cl_R rem (const cl_R& x, const cl_R& y);
0339 
0340 
0341 // rational(x) liefert (rational x), wo x eine reelle Zahl ist.
0342 extern const cl_RA rational (const cl_R& x);
0343 // Spezialfall:
0344 inline const cl_RA rational (const cl_RA& x) { return x; }
0345 
0346 
0347 // equal(x,y) vergleicht zwei reelle Zahlen x und y auf Gleichheit.
0348 extern bool equal (const cl_R& x, const cl_R& y);
0349 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
0350 extern uint32 equal_hashcode (const cl_R& x);
0351 
0352 // compare(x,y) vergleicht zwei reelle Zahlen x und y.
0353 // Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
0354 extern cl_signean compare (const cl_R& x, const cl_R& y);
0355 
0356 inline bool operator== (const cl_R& x, const cl_R& y)
0357     { return equal(x,y); }
0358 inline bool operator!= (const cl_R& x, const cl_R& y)
0359     { return !equal(x,y); }
0360 inline bool operator<= (const cl_R& x, const cl_R& y)
0361     { return compare(x,y)<=0; }
0362 inline bool operator< (const cl_R& x, const cl_R& y)
0363     { return compare(x,y)<0; }
0364 inline bool operator>= (const cl_R& x, const cl_R& y)
0365     { return compare(x,y)>=0; }
0366 inline bool operator> (const cl_R& x, const cl_R& y)
0367     { return compare(x,y)>0; }
0368 
0369 // max(x,y) liefert (max x y), wo x und y reelle Zahlen sind.
0370 extern const cl_R max (const cl_R& x, const cl_R& y);
0371 
0372 // min(x,y) liefert (min x y), wo x und y reelle Zahlen sind.
0373 extern const cl_R min (const cl_R& x, const cl_R& y);
0374 
0375 // signum(x) liefert (signum x), wo x eine reelle Zahl ist.
0376 extern const cl_R signum (const cl_R& x);
0377 
0378 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer reellen Zahl x >=0.
0379 extern const cl_R sqrt (const cl_R& x);
0380 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer rationalen Zahl x >=0.
0381 extern const cl_R sqrt (const cl_RA& x);
0382 
0383 // (expt x y), wo x eine reelle Zahl und y ein Integer ist.
0384 extern const cl_R expt (const cl_R& x, sintL y);
0385 extern const cl_R expt (const cl_R& x, const cl_I& y);
0386 
0387 // rationalize(x) liefert (rationalize x), wo x eine reelle Zahl ist.
0388 extern const cl_RA rationalize (const cl_R& x);
0389 
0390 
0391 // Konversion zu einem C "float".
0392 extern float float_approx (const cl_R& x);
0393 
0394 // Konversion zu einem C "double".
0395 extern double double_approx (const cl_R& x);
0396 
0397 
0398 // Transcendental functions
0399 
0400 
0401 // atan(x,y) liefert zu zwei reellen Zahlen x, y den Winkel von (x,y)
0402 // in Polarkoordinaten. Ergebnis rational nur, wenn x>0 und y=0.
0403 extern const cl_R atan (const cl_R& x, const cl_R& y);
0404 // Spezialfall: y Float -> Ergebnis Float
0405 inline const cl_F atan (const cl_R& x, const cl_F& y)
0406     { return The(cl_F)(atan(x,The(cl_R)(y))); }
0407 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0408 inline const cl_R atan (const cl_R& x, const int y)
0409     { return atan(x,cl_I(y)); }
0410 inline const cl_R atan (const cl_R& x, const unsigned int y)
0411     { return atan(x,cl_I(y)); }
0412 inline const cl_R atan (const cl_R& x, const long y)
0413     { return atan(x,cl_I(y)); }
0414 inline const cl_R atan (const cl_R& x, const unsigned long y)
0415     { return atan(x,cl_I(y)); }
0416 
0417 // atan(x) liefert den Arctan einer reellen Zahl x.
0418 // Ergebnis rational nur, wenn x=0.
0419 extern const cl_R atan (const cl_R& x);
0420 // Spezialfall: x Float -> Ergebnis Float
0421 inline const cl_F atan (const cl_F& x) { return The(cl_F)(atan(The(cl_R)(x))); }
0422 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0423 inline const cl_R atan (const int x) { return atan(cl_I(x)); }
0424 inline const cl_R atan (const unsigned int x) { return atan(cl_I(x)); }
0425 inline const cl_R atan (const long x) { return atan(cl_I(x)); }
0426 inline const cl_R atan (const unsigned long x) { return atan(cl_I(x)); }
0427 
0428 // sin(x) liefert den Sinus (sin x) einer reellen Zahl x.
0429 extern const cl_R sin (const cl_R& x);
0430 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0431 inline const cl_R sin (const int x) { return sin(cl_I(x)); }
0432 inline const cl_R sin (const unsigned int x) { return sin(cl_I(x)); }
0433 inline const cl_R sin (const long x) { return sin(cl_I(x)); }
0434 inline const cl_R sin (const unsigned long x) { return sin(cl_I(x)); }
0435 
0436 // cos(x) liefert den Cosinus (cos x) einer reellen Zahl x.
0437 extern const cl_R cos (const cl_R& x);
0438 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0439 inline const cl_R cos (const int x) { return cos(cl_I(x)); }
0440 inline const cl_R cos (const unsigned int x) { return cos(cl_I(x)); }
0441 inline const cl_R cos (const long x) { return cos(cl_I(x)); }
0442 inline const cl_R cos (const unsigned long x) { return cos(cl_I(x)); }
0443 
0444 // cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
0445 extern const cos_sin_t cos_sin (const cl_R& x);
0446 
0447 // tan(x) liefert den Tangens (tan x) einer reellen Zahl x.
0448 extern const cl_R tan (const cl_R& x);
0449 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0450 inline const cl_R tan (const int x) { return tan(cl_I(x)); }
0451 inline const cl_R tan (const unsigned int x) { return tan(cl_I(x)); }
0452 inline const cl_R tan (const long x) { return tan(cl_I(x)); }
0453 inline const cl_R tan (const unsigned long x) { return tan(cl_I(x)); }
0454 
0455 // ln(x) liefert zu einer reellen Zahl x>0 die Zahl ln(x).
0456 extern const cl_R ln (const cl_R& x);
0457 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0458 inline const cl_R ln (const int x) { return ln(cl_I(x)); }
0459 inline const cl_R ln (const unsigned int x) { return ln(cl_I(x)); }
0460 inline const cl_R ln (const long x) { return ln(cl_I(x)); }
0461 inline const cl_R ln (const unsigned long x) { return ln(cl_I(x)); }
0462 
0463 // log(a,b) liefert zu reellen Zahlen a>0, b>0 die Zahl
0464 // log(a,b)=ln(a)/ln(b).
0465 // Ergebnis rational nur, wenn a=1 oder a und b rational.
0466 extern const cl_R log (const cl_R& a, const cl_R& b);
0467 
0468 // exp(x) liefert zu einer reellen Zahl x die Zahl exp(x).
0469 extern const cl_R exp (const cl_R& x);
0470 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0471 inline const cl_R exp (const int x) { return exp(cl_I(x)); }
0472 inline const cl_R exp (const unsigned int x) { return exp(cl_I(x)); }
0473 inline const cl_R exp (const long x) { return exp(cl_I(x)); }
0474 inline const cl_R exp (const unsigned long x) { return exp(cl_I(x)); }
0475 
0476 // sinh(x) liefert zu einer reellen Zahl x die Zahl sinh(x).
0477 extern const cl_R sinh (const cl_R& x);
0478 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0479 inline const cl_R sinh (const int x) { return sinh(cl_I(x)); }
0480 inline const cl_R sinh (const unsigned int x) { return sinh(cl_I(x)); }
0481 inline const cl_R sinh (const long x) { return sinh(cl_I(x)); }
0482 inline const cl_R sinh (const unsigned long x) { return sinh(cl_I(x)); }
0483 
0484 // cosh(x) liefert zu einer reellen Zahl x die Zahl cosh(x).
0485 extern const cl_R cosh (const cl_R& x);
0486 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0487 inline const cl_R cosh (const int x) { return cosh(cl_I(x)); }
0488 inline const cl_R cosh (const unsigned int x) { return cosh(cl_I(x)); }
0489 inline const cl_R cosh (const long x) { return cosh(cl_I(x)); }
0490 inline const cl_R cosh (const unsigned long x) { return cosh(cl_I(x)); }
0491 
0492 // cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
0493 extern const cosh_sinh_t cosh_sinh (const cl_R& x);
0494 
0495 // tanh(x) liefert zu einer reellen Zahl x die Zahl tanh(x).
0496 extern const cl_R tanh (const cl_R& x);
0497 // Dem C++-Compiler muß man nun auch das Folgende sagen:
0498 inline const cl_R tanh (const int x) { return tanh(cl_I(x)); }
0499 inline const cl_R tanh (const unsigned int x) { return tanh(cl_I(x)); }
0500 inline const cl_R tanh (const long x) { return tanh(cl_I(x)); }
0501 inline const cl_R tanh (const unsigned long x) { return tanh(cl_I(x)); }
0502 
0503 
0504 // random_R(randomstate,n) liefert zu einer reellen Zahl n>0 eine Zufallszahl
0505 // x mit 0 <= x < n.
0506 extern const cl_R random_R (random_state& randomstate, const cl_R& n);
0507 
0508 inline const cl_R random_R (const cl_R& n)
0509     { return random_R(default_random_state,n); }
0510 
0511 
0512 // This could be optimized to use in-place operations.
0513 inline cl_R& operator+= (cl_R& x, const cl_R& y) { return x = x + y; }
0514 inline cl_F& operator+= (cl_F& x, const cl_R& y) { return x = x + y; }
0515 inline cl_F& operator+= (cl_F& x, const cl_RA& y) { return x = x + y; }
0516 inline cl_F& operator+= (cl_F& x, const cl_I& y) { return x = x + y; }
0517 inline cl_R& operator+= (cl_R& x, const int y) { return x = x + y; }
0518 inline cl_R& operator+= (cl_R& x, const unsigned int y) { return x = x + y; }
0519 inline cl_R& operator+= (cl_R& x, const long y) { return x = x + y; }
0520 inline cl_R& operator+= (cl_R& x, const unsigned long y) { return x = x + y; }
0521 inline cl_R& operator+= (cl_R& x, const long long y) { return x = x + y; }
0522 inline cl_R& operator+= (cl_R& x, const unsigned long long y) { return x = x + y; }
0523 inline cl_F& operator+= (cl_R& x, const float y) { return static_cast<cl_F&>(x = x + y); }
0524 inline cl_F& operator+= (cl_R& x, const double y) { return static_cast<cl_F&>(x = x + y); }
0525 inline cl_F& operator+= (cl_F& x, const int y) { return x = x + y; }
0526 inline cl_F& operator+= (cl_F& x, const unsigned int y) { return x = x + y; }
0527 inline cl_F& operator+= (cl_F& x, const long y) { return x = x + y; }
0528 inline cl_F& operator+= (cl_F& x, const unsigned long y) { return x = x + y; }
0529 inline cl_F& operator+= (cl_F& x, const long long y) { return x = x + y; }
0530 inline cl_F& operator+= (cl_F& x, const unsigned long long y) { return x = x + y; }
0531 inline cl_R& operator++ /* prefix */ (cl_R& x) { return x = plus1(x); }
0532 inline void operator++ /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = plus1(x); }
0533 inline cl_R& operator-= (cl_R& x, const cl_R& y) { return x = x - y; }
0534 inline cl_F& operator-= (cl_F& x, const cl_R& y) { return x = x - y; }
0535 inline cl_F& operator-= (cl_F& x, const cl_RA& y) { return x = x - y; }
0536 inline cl_F& operator-= (cl_F& x, const cl_I& y) { return x = x - y; }
0537 inline cl_R& operator-= (cl_R& x, const int y) { return x = x - y; }
0538 inline cl_R& operator-= (cl_R& x, const unsigned int y) { return x = x - y; }
0539 inline cl_R& operator-= (cl_R& x, const long y) { return x = x - y; }
0540 inline cl_R& operator-= (cl_R& x, const unsigned long y) { return x = x - y; }
0541 inline cl_R& operator-= (cl_R& x, const long long y) { return x = x - y; }
0542 inline cl_R& operator-= (cl_R& x, const unsigned long long y) { return x = x - y; }
0543 inline cl_F& operator-= (cl_R& x, const float y) { return static_cast<cl_F&>(x = x - y); }
0544 inline cl_F& operator-= (cl_R& x, const double y) { return static_cast<cl_F&>(x = x - y); }
0545 inline cl_F& operator-= (cl_F& x, const int y) { return x = x - y; }
0546 inline cl_F& operator-= (cl_F& x, const unsigned int y) { return x = x - y; }
0547 inline cl_F& operator-= (cl_F& x, const long y) { return x = x - y; }
0548 inline cl_F& operator-= (cl_F& x, const unsigned long y) { return x = x - y; }
0549 inline cl_F& operator-= (cl_F& x, const long long y) { return x = x - y; }
0550 inline cl_F& operator-= (cl_F& x, const unsigned long long y) { return x = x - y; }
0551 inline cl_R& operator-- /* prefix */ (cl_R& x) { return x = minus1(x); }
0552 inline void operator-- /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = minus1(x); }
0553 inline cl_R& operator*= (cl_R& x, const cl_R& y) { return x = x * y; }
0554 inline cl_R& operator*= (cl_R& x, const int y) { return x = x * y; }
0555 inline cl_R& operator*= (cl_R& x, const unsigned int y) { return x = x * y; }
0556 inline cl_R& operator*= (cl_R& x, const long y) { return x = x * y; }
0557 inline cl_R& operator*= (cl_R& x, const unsigned long y) { return x = x * y; }
0558 inline cl_R& operator*= (cl_R& x, const long long y) { return x = x * y; }
0559 inline cl_R& operator*= (cl_R& x, const unsigned long long y) { return x = x * y; }
0560 inline cl_R& operator*= (cl_R& x, const float y) { return x = x * y; }
0561 inline cl_R& operator*= (cl_R& x, const double y) { return x = x * y; }
0562 inline cl_R& operator/= (cl_R& x, const cl_R& y) { return x = x / y; }
0563 inline cl_F& operator/= (cl_F& x, const cl_R& y) { return x = x / y; }
0564 inline cl_F& operator/= (cl_F& x, const cl_RA& y) { return x = x / y; }
0565 inline cl_F& operator/= (cl_F& x, const cl_I& y) { return x = x / y; }
0566 inline cl_R& operator/= (cl_R& x, const int y) { return x = x / y; }
0567 inline cl_R& operator/= (cl_R& x, const unsigned int y) { return x = x / y; }
0568 inline cl_R& operator/= (cl_R& x, const long y) { return x = x / y; }
0569 inline cl_R& operator/= (cl_R& x, const unsigned long y) { return x = x / y; }
0570 inline cl_R& operator/= (cl_R& x, const long long y) { return x = x / y; }
0571 inline cl_R& operator/= (cl_R& x, const unsigned long long y) { return x = x / y; }
0572 inline cl_R& operator/= (cl_R& x, const float y) { return x = x / y; }
0573 inline cl_R& operator/= (cl_R& x, const double y) { return x = x / y; }
0574 inline cl_F& operator/= (cl_F& x, const int y) { return x = x / y; }
0575 inline cl_F& operator/= (cl_F& x, const unsigned int y) { return x = x / y; }
0576 inline cl_F& operator/= (cl_F& x, const long y) { return x = x / y; }
0577 inline cl_F& operator/= (cl_F& x, const unsigned long y) { return x = x / y; }
0578 inline cl_F& operator/= (cl_F& x, const long long y) { return x = x / y; }
0579 inline cl_F& operator/= (cl_F& x, const unsigned long long y) { return x = x / y; }
0580 
0581 
0582 // Complex operations, trivial for reals
0583 
0584 inline const cl_R realpart (const cl_R& x)
0585 {
0586     return x;
0587 }
0588 inline const cl_R imagpart (const cl_R& x)
0589 {
0590     (void)x; // unused x
0591     return 0;
0592 }
0593 inline const cl_R conjugate (const cl_R& x)
0594 {
0595     return x;
0596 }
0597 
0598 
0599 // Debugging support.
0600 #ifdef CL_DEBUG
0601 extern int cl_R_debug_module;
0602 CL_FORCE_LINK(cl_R_debug_dummy, cl_R_debug_module)
0603 #endif
0604 
0605 }  // namespace cln
0606 
0607 #endif /* _CL_REAL_H */