]> www.ginac.de Git - cln.git/blobdiff - include/cln/real.h
Replace CL_REQUIRE/CL_PROVIDE(cl_prin_globals) with portable code.
[cln.git] / include / cln / real.h
index 5c2a2bdeadfd1a5e6f4c0ac06fad8d02f2893bad..cfcc631f0706b24d29425812a12ed4d9364e683b 100644 (file)
@@ -17,13 +17,13 @@ CL_DEFINE_AS_CONVERSION(cl_R)
 
 
 // zerop(x) testet, ob (= x 0).
-extern cl_boolean zerop (const cl_R& x);
+extern bool zerop (const cl_R& x);
 
 // minusp(x) testet, ob (< x 0).
-extern cl_boolean minusp (const cl_R& x);
+extern bool minusp (const cl_R& x);
 
 // plusp(x) testet, ob (> x 0).
-extern cl_boolean plusp (const cl_R& x);
+extern bool plusp (const cl_R& x);
 
 
 // R_to_SF(x) wandelt eine reelle Zahl x in ein Short-Float um.
@@ -39,29 +39,29 @@ extern const cl_FF cl_R_to_FF (const cl_R& x);
 extern const cl_DF cl_R_to_DF (const cl_R& x);
 
 // R_to_LF(x,len) wandelt eine reelle Zahl x in ein Long-Float mit len Digits um.
-// > uintC len: gewünschte Anzahl Digits, >=LF_minlen
+// > uintC len: gewünschte Anzahl Digits, >=LF_minlen
 // < ergebnis: (coerce x `(long-float ,len))
 extern const cl_LF cl_R_to_LF (const cl_R& x, uintC len);
 
 // cl_float(x,y) wandelt eine reelle Zahl x in das Float-Format des
-// Floats y um und rundet dabei nötigenfalls.
+// Floats y um und rundet dabei nötigenfalls.
 // > x: eine reelle Zahl
 // > y: ein Float
 // < ergebnis: (float x y)
 extern const cl_F cl_float (const cl_R& x, const cl_F& y);
 
 // cl_float(x,f) wandelt eine reelle Zahl x in das Float-Format f um
-// und rundet dabei nötigenfalls.
+// und rundet dabei nötigenfalls.
 // > x: eine reelle Zahl
 // > f: eine Float-Format-Spezifikation
 // < ergebnis: (float x f)
 extern const cl_F cl_float (const cl_R& x, float_format_t f);
 
 // cl_float(x) wandelt eine reelle Zahl x in ein Float um
-// und rundet dabei nötigenfalls.
+// und rundet dabei nötigenfalls.
 // > x: eine reelle Zahl
 // < ergebnis: (float x)
-// Abhängig von default_float_format.
+// Abhängig von default_float_format.
 extern const cl_F cl_float (const cl_R& x);
 
 
@@ -75,7 +75,7 @@ inline const cl_F operator+ (const cl_R& x, const cl_F& y)
        { return The(cl_F)(x + The(cl_R)(y)); }
 inline const cl_F operator+ (const cl_F& x, const cl_R& y)
        { return The(cl_F)(The(cl_R)(x) + y); }
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R operator+ (const int x, const cl_R& y)
        { return cl_I(x) + y; }
 inline const cl_R operator+ (const unsigned int x, const cl_R& y)
@@ -84,6 +84,12 @@ inline const cl_R operator+ (const long x, const cl_R& y)
        { return cl_I(x) + y; }
 inline const cl_R operator+ (const unsigned long x, const cl_R& y)
        { return cl_I(x) + y; }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator+ (const long long x, const cl_R& y)
+       { return cl_I(x) + y; }
+inline const cl_R operator+ (const unsigned long long x, const cl_R& y)
+       { return cl_I(x) + y; }
+#endif
 inline const cl_F operator+ (const float x, const cl_R& y)
        { return The(cl_F)(cl_R(x) + y); }
 inline const cl_F operator+ (const double x, const cl_R& y)
@@ -96,6 +102,12 @@ inline const cl_R operator+ (const cl_R& x, const long y)
        { return x + cl_I(y); }
 inline const cl_R operator+ (const cl_R& x, const unsigned long y)
        { return x + cl_I(y); }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator+ (const cl_R& x, const long long y)
+       { return x + cl_I(y); }
+inline const cl_R operator+ (const cl_R& x, const unsigned long long y)
+       { return x + cl_I(y); }
+#endif
 inline const cl_F operator+ (const cl_R& x, const float y)
        { return The(cl_F)(x + cl_R(y)); }
 inline const cl_F operator+ (const cl_R& x, const double y)
@@ -108,7 +120,7 @@ inline const cl_F operator- (const cl_R& x, const cl_F& y)
        { return The(cl_F)(x - The(cl_R)(y)); }
 inline const cl_F operator- (const cl_F& x, const cl_R& y)
        { return The(cl_F)(The(cl_R)(x) - y); }
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R operator- (const int x, const cl_R& y)
        { return cl_I(x) - y; }
 inline const cl_R operator- (const unsigned int x, const cl_R& y)
@@ -117,6 +129,12 @@ inline const cl_R operator- (const long x, const cl_R& y)
        { return cl_I(x) - y; }
 inline const cl_R operator- (const unsigned long x, const cl_R& y)
        { return cl_I(x) - y; }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator- (const long long x, const cl_R& y)
+       { return cl_I(x) - y; }
+inline const cl_R operator- (const unsigned long long x, const cl_R& y)
+       { return cl_I(x) - y; }
+#endif
 inline const cl_F operator- (const float x, const cl_R& y)
        { return The(cl_F)(cl_R(x) - y); }
 inline const cl_F operator- (const double x, const cl_R& y)
@@ -129,6 +147,12 @@ inline const cl_R operator- (const cl_R& x, const long y)
        { return x - cl_I(y); }
 inline const cl_R operator- (const cl_R& x, const unsigned long y)
        { return x - cl_I(y); }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator- (const cl_R& x, const long long y)
+       { return x - cl_I(y); }
+inline const cl_R operator- (const cl_R& x, const unsigned long long y)
+       { return x - cl_I(y); }
+#endif
 inline const cl_F operator- (const cl_R& x, const float y)
        { return The(cl_F)(x - cl_R(y)); }
 inline const cl_F operator- (const cl_R& x, const double y)
@@ -136,7 +160,7 @@ inline const cl_F operator- (const cl_R& x, const double y)
 
 // Liefert (* x y), wo x und y reelle Zahlen sind.
 extern const cl_R operator* (const cl_R& x, const cl_R& y);
-// Dem C++-Compiler muß man auch das Folgende sagen (wg. `int * cl_F' u.ä.):
+// Dem C++-Compiler muß man auch das Folgende sagen (wg. `int * cl_F' u.ä.):
 inline const cl_R operator* (const int x, const cl_R& y)
        { return cl_I(x) * y; }
 inline const cl_R operator* (const unsigned int x, const cl_R& y)
@@ -145,6 +169,12 @@ inline const cl_R operator* (const long x, const cl_R& y)
        { return cl_I(x) * y; }
 inline const cl_R operator* (const unsigned long x, const cl_R& y)
        { return cl_I(x) * y; }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator* (const long long x, const cl_R& y)
+       { return cl_I(x) * y; }
+inline const cl_R operator* (const unsigned long long x, const cl_R& y)
+       { return cl_I(x) * y; }
+#endif
 inline const cl_R operator* (const float x, const cl_R& y)
        { return cl_R(x) * y; }
 inline const cl_R operator* (const double x, const cl_R& y)
@@ -157,6 +187,12 @@ inline const cl_R operator* (const cl_R& x, const long y)
        { return x * cl_I(y); }
 inline const cl_R operator* (const cl_R& x, const unsigned long y)
        { return x * cl_I(y); }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator* (const cl_R& x, const long long y)
+       { return x * cl_I(y); }
+inline const cl_R operator* (const cl_R& x, const unsigned long long y)
+       { return x * cl_I(y); }
+#endif
 inline const cl_R operator* (const cl_R& x, const float y)
        { return x * cl_R(y); }
 inline const cl_R operator* (const cl_R& x, const double y)
@@ -170,7 +206,7 @@ extern const cl_R operator/ (const cl_R& x, const cl_R& y);
 // Spezialfall: x Float -> Ergebnis Float
 inline const cl_F operator/ (const cl_F& x, const cl_R& y)
        { return The(cl_F)(The(cl_R)(x) / y); }
-// Dem C++-Compiler muß man auch das Folgende sagen (wg. `int / cl_F' u.ä.):
+// Dem C++-Compiler muß man auch das Folgende sagen (wg. `int / cl_F' u.ä.):
 inline const cl_R operator/ (const int x, const cl_R& y)
        { return cl_I(x) / y; }
 inline const cl_R operator/ (const unsigned int x, const cl_R& y)
@@ -179,6 +215,12 @@ inline const cl_R operator/ (const long x, const cl_R& y)
        { return cl_I(x) / y; }
 inline const cl_R operator/ (const unsigned long x, const cl_R& y)
        { return cl_I(x) / y; }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator/ (const long long x, const cl_R& y)
+       { return cl_I(x) / y; }
+inline const cl_R operator/ (const unsigned long long x, const cl_R& y)
+       { return cl_I(x) / y; }
+#endif
 inline const cl_F operator/ (const float x, const cl_R& y)
        { return The(cl_F)(cl_R(x) / y); }
 inline const cl_F operator/ (const double x, const cl_R& y)
@@ -191,6 +233,12 @@ inline const cl_R operator/ (const cl_R& x, const long y)
        { return x / cl_I(y); }
 inline const cl_R operator/ (const cl_R& x, const unsigned long y)
        { return x / cl_I(y); }
+#ifdef HAVE_LONGLONG
+inline const cl_R operator/ (const cl_R& x, const long long y)
+       { return x / cl_I(y); }
+inline const cl_R operator/ (const cl_R& x, const unsigned long long y)
+       { return x / cl_I(y); }
+#endif
 inline const cl_R operator/ (const cl_R& x, const float y)
        { return x / cl_R(y); }
 inline const cl_R operator/ (const cl_R& x, const double y)
@@ -313,8 +361,8 @@ inline const cl_RA rational (const cl_RA& x) { return x; }
 
 
 // equal(x,y) vergleicht zwei reelle Zahlen x und y auf Gleichheit.
-extern cl_boolean equal (const cl_R& x, const cl_R& y);
-// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
+extern bool equal (const cl_R& x, const cl_R& y);
+// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
 extern uint32 equal_hashcode (const cl_R& x);
 
 // compare(x,y) vergleicht zwei reelle Zahlen x und y.
@@ -372,7 +420,7 @@ extern const cl_R atan (const cl_R& x, const cl_R& y);
 // Spezialfall: y Float -> Ergebnis Float
 inline const cl_F atan (const cl_R& x, const cl_F& y)
        { return The(cl_F)(atan(x,The(cl_R)(y))); }
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R atan (const cl_R& x, const int y)
        { return atan(x,cl_I(y)); }
 inline const cl_R atan (const cl_R& x, const unsigned int y)
@@ -387,7 +435,7 @@ inline const cl_R atan (const cl_R& x, const unsigned long y)
 extern const cl_R atan (const cl_R& x);
 // Spezialfall: x Float -> Ergebnis Float
 inline const cl_F atan (const cl_F& x) { return The(cl_F)(atan(The(cl_R)(x))); }
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R atan (const int x) { return atan(cl_I(x)); }
 inline const cl_R atan (const unsigned int x) { return atan(cl_I(x)); }
 inline const cl_R atan (const long x) { return atan(cl_I(x)); }
@@ -395,7 +443,7 @@ inline const cl_R atan (const unsigned long x) { return atan(cl_I(x)); }
 
 // sin(x) liefert den Sinus (sin x) einer reellen Zahl x.
 extern const cl_R sin (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R sin (const int x) { return sin(cl_I(x)); }
 inline const cl_R sin (const unsigned int x) { return sin(cl_I(x)); }
 inline const cl_R sin (const long x) { return sin(cl_I(x)); }
@@ -403,7 +451,7 @@ inline const cl_R sin (const unsigned long x) { return sin(cl_I(x)); }
 
 // cos(x) liefert den Cosinus (cos x) einer reellen Zahl x.
 extern const cl_R cos (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R cos (const int x) { return cos(cl_I(x)); }
 inline const cl_R cos (const unsigned int x) { return cos(cl_I(x)); }
 inline const cl_R cos (const long x) { return cos(cl_I(x)); }
@@ -414,7 +462,7 @@ extern const cos_sin_t cos_sin (const cl_R& x);
 
 // tan(x) liefert den Tangens (tan x) einer reellen Zahl x.
 extern const cl_R tan (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R tan (const int x) { return tan(cl_I(x)); }
 inline const cl_R tan (const unsigned int x) { return tan(cl_I(x)); }
 inline const cl_R tan (const long x) { return tan(cl_I(x)); }
@@ -422,7 +470,7 @@ inline const cl_R tan (const unsigned long x) { return tan(cl_I(x)); }
 
 // ln(x) liefert zu einer reellen Zahl x>0 die Zahl ln(x).
 extern const cl_R ln (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R ln (const int x) { return ln(cl_I(x)); }
 inline const cl_R ln (const unsigned int x) { return ln(cl_I(x)); }
 inline const cl_R ln (const long x) { return ln(cl_I(x)); }
@@ -435,7 +483,7 @@ extern const cl_R log (const cl_R& a, const cl_R& b);
 
 // exp(x) liefert zu einer reellen Zahl x die Zahl exp(x).
 extern const cl_R exp (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R exp (const int x) { return exp(cl_I(x)); }
 inline const cl_R exp (const unsigned int x) { return exp(cl_I(x)); }
 inline const cl_R exp (const long x) { return exp(cl_I(x)); }
@@ -443,7 +491,7 @@ inline const cl_R exp (const unsigned long x) { return exp(cl_I(x)); }
 
 // sinh(x) liefert zu einer reellen Zahl x die Zahl sinh(x).
 extern const cl_R sinh (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R sinh (const int x) { return sinh(cl_I(x)); }
 inline const cl_R sinh (const unsigned int x) { return sinh(cl_I(x)); }
 inline const cl_R sinh (const long x) { return sinh(cl_I(x)); }
@@ -451,7 +499,7 @@ inline const cl_R sinh (const unsigned long x) { return sinh(cl_I(x)); }
 
 // cosh(x) liefert zu einer reellen Zahl x die Zahl cosh(x).
 extern const cl_R cosh (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R cosh (const int x) { return cosh(cl_I(x)); }
 inline const cl_R cosh (const unsigned int x) { return cosh(cl_I(x)); }
 inline const cl_R cosh (const long x) { return cosh(cl_I(x)); }
@@ -462,7 +510,7 @@ extern const cosh_sinh_t cosh_sinh (const cl_R& x);
 
 // tanh(x) liefert zu einer reellen Zahl x die Zahl tanh(x).
 extern const cl_R tanh (const cl_R& x);
-// Dem C++-Compiler muß man nun auch das Folgende sagen:
+// Dem C++-Compiler muß man nun auch das Folgende sagen:
 inline const cl_R tanh (const int x) { return tanh(cl_I(x)); }
 inline const cl_R tanh (const unsigned int x) { return tanh(cl_I(x)); }
 inline const cl_R tanh (const long x) { return tanh(cl_I(x)); }
@@ -477,7 +525,6 @@ inline const cl_R random_R (const cl_R& n)
        { return random_R(default_random_state,n); }
 
 
-#ifdef WANT_OBFUSCATING_OPERATORS
 // This could be optimized to use in-place operations.
 inline cl_R& operator+= (cl_R& x, const cl_R& y) { return x = x + y; }
 inline cl_F& operator+= (cl_F& x, const cl_R& y) { return x = x + y; }
@@ -487,12 +534,20 @@ inline cl_R& operator+= (cl_R& x, const int y) { return x = x + y; }
 inline cl_R& operator+= (cl_R& x, const unsigned int y) { return x = x + y; }
 inline cl_R& operator+= (cl_R& x, const long y) { return x = x + y; }
 inline cl_R& operator+= (cl_R& x, const unsigned long y) { return x = x + y; }
+#ifdef HAVE_LONGLONG
+inline cl_R& operator+= (cl_R& x, const long long y) { return x = x + y; }
+inline cl_R& operator+= (cl_R& x, const unsigned long long y) { return x = x + y; }
+#endif
 inline cl_F& operator+= (cl_R& x, const float y) { return static_cast<cl_F&>(x = x + y); }
 inline cl_F& operator+= (cl_R& x, const double y) { return static_cast<cl_F&>(x = x + y); }
 inline cl_F& operator+= (cl_F& x, const int y) { return x = x + y; }
 inline cl_F& operator+= (cl_F& x, const unsigned int y) { return x = x + y; }
 inline cl_F& operator+= (cl_F& x, const long y) { return x = x + y; }
 inline cl_F& operator+= (cl_F& x, const unsigned long y) { return x = x + y; }
+#ifdef HAVE_LONGLONG
+inline cl_F& operator+= (cl_F& x, const long long y) { return x = x + y; }
+inline cl_F& operator+= (cl_F& x, const unsigned long long y) { return x = x + y; }
+#endif
 inline cl_R& operator++ /* prefix */ (cl_R& x) { return x = plus1(x); }
 inline void operator++ /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = plus1(x); }
 inline cl_R& operator-= (cl_R& x, const cl_R& y) { return x = x - y; }
@@ -503,12 +558,20 @@ inline cl_R& operator-= (cl_R& x, const int y) { return x = x - y; }
 inline cl_R& operator-= (cl_R& x, const unsigned int y) { return x = x - y; }
 inline cl_R& operator-= (cl_R& x, const long y) { return x = x - y; }
 inline cl_R& operator-= (cl_R& x, const unsigned long y) { return x = x - y; }
+#ifdef HAVE_LONGLONG
+inline cl_R& operator-= (cl_R& x, const long long y) { return x = x - y; }
+inline cl_R& operator-= (cl_R& x, const unsigned long long y) { return x = x - y; }
+#endif
 inline cl_F& operator-= (cl_R& x, const float y) { return static_cast<cl_F&>(x = x - y); }
 inline cl_F& operator-= (cl_R& x, const double y) { return static_cast<cl_F&>(x = x - y); }
 inline cl_F& operator-= (cl_F& x, const int y) { return x = x - y; }
 inline cl_F& operator-= (cl_F& x, const unsigned int y) { return x = x - y; }
 inline cl_F& operator-= (cl_F& x, const long y) { return x = x - y; }
 inline cl_F& operator-= (cl_F& x, const unsigned long y) { return x = x - y; }
+#ifdef HAVE_LONGLONG
+inline cl_F& operator-= (cl_F& x, const long long y) { return x = x - y; }
+inline cl_F& operator-= (cl_F& x, const unsigned long long y) { return x = x - y; }
+#endif
 inline cl_R& operator-- /* prefix */ (cl_R& x) { return x = minus1(x); }
 inline void operator-- /* postfix */ (cl_R& x, int dummy) { (void)dummy; x = minus1(x); }
 inline cl_R& operator*= (cl_R& x, const cl_R& y) { return x = x * y; }
@@ -516,6 +579,10 @@ inline cl_R& operator*= (cl_R& x, const int y) { return x = x * y; }
 inline cl_R& operator*= (cl_R& x, const unsigned int y) { return x = x * y; }
 inline cl_R& operator*= (cl_R& x, const long y) { return x = x * y; }
 inline cl_R& operator*= (cl_R& x, const unsigned long y) { return x = x * y; }
+#ifdef HAVE_LONGLONG
+inline cl_R& operator*= (cl_R& x, const long long y) { return x = x * y; }
+inline cl_R& operator*= (cl_R& x, const unsigned long long y) { return x = x * y; }
+#endif
 inline cl_R& operator*= (cl_R& x, const float y) { return x = x * y; }
 inline cl_R& operator*= (cl_R& x, const double y) { return x = x * y; }
 inline cl_R& operator/= (cl_R& x, const cl_R& y) { return x = x / y; }
@@ -526,12 +593,19 @@ inline cl_R& operator/= (cl_R& x, const int y) { return x = x / y; }
 inline cl_R& operator/= (cl_R& x, const unsigned int y) { return x = x / y; }
 inline cl_R& operator/= (cl_R& x, const long y) { return x = x / y; }
 inline cl_R& operator/= (cl_R& x, const unsigned long y) { return x = x / y; }
+#ifdef HAVE_LONGLONG
+inline cl_R& operator/= (cl_R& x, const long long y) { return x = x / y; }
+inline cl_R& operator/= (cl_R& x, const unsigned long long y) { return x = x / y; }
+#endif
 inline cl_R& operator/= (cl_R& x, const float y) { return x = x / y; }
 inline cl_R& operator/= (cl_R& x, const double y) { return x = x / y; }
 inline cl_F& operator/= (cl_F& x, const int y) { return x = x / y; }
 inline cl_F& operator/= (cl_F& x, const unsigned int y) { return x = x / y; }
 inline cl_F& operator/= (cl_F& x, const long y) { return x = x / y; }
 inline cl_F& operator/= (cl_F& x, const unsigned long y) { return x = x / y; }
+#ifdef HAVE_LONGLONG
+inline cl_F& operator/= (cl_F& x, const long long y) { return x = x / y; }
+inline cl_F& operator/= (cl_F& x, const unsigned long long y) { return x = x / y; }
 #endif