Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Public complex number operations.
0002 
0003 #ifndef _CL_COMPLEX_H
0004 #define _CL_COMPLEX_H
0005 
0006 #include "cln/number.h"
0007 #include "cln/complex_class.h"
0008 #include "cln/real_class.h"
0009 #include "cln/integer_class.h"
0010 
0011 namespace cln {
0012 
0013 CL_DEFINE_AS_CONVERSION(cl_N)
0014 
0015 
0016 // zerop(x) testet, ob (= x 0).
0017 extern bool zerop (const cl_N& x);
0018 
0019 
0020 // Liefert zu reellen Zahlen a und b die komplexe Zahl a+bi.
0021 // complex(a,b)
0022 extern const cl_N complex (const cl_R& a, const cl_R& b);
0023 
0024 // realpart(x) liefert den Realteil der Zahl x.
0025 extern const cl_R realpart (const cl_N& x);
0026 
0027 // imagpart(x) liefert den Imaginärteil der Zahl x.
0028 extern const cl_R imagpart (const cl_N& x);
0029 
0030 // conjugate(x) liefert die konjugiert komplexe Zahl zur Zahl x.
0031 extern const cl_N conjugate (const cl_N& x);
0032 
0033 
0034 // Liefert (- x), wo x eine Zahl ist.
0035 extern const cl_N operator- (const cl_N& x);
0036 
0037 // Liefert (+ x y), wo x und y Zahlen sind.
0038 extern const cl_N operator+ (const cl_N& x, const cl_N& y);
0039 
0040 // Liefert (- x y), wo x und y Zahlen sind.
0041 extern const cl_N operator- (const cl_N& x, const cl_N& y);
0042 
0043 // Liefert (* x y), wo x und y Zahlen sind.
0044 extern const cl_N operator* (const cl_N& x, const cl_N& y);
0045 
0046 // Liefert (* x x), wo x eine Zahl ist.
0047 extern const cl_N square (const cl_N& x);
0048 
0049 // Liefert (/ x y), wo x und y Zahlen sind.
0050 extern const cl_N operator/ (const cl_N& x, const cl_N& y);
0051 
0052 // Liefert (abs x), wo x eine Zahl ist.
0053 extern const cl_R abs (const cl_N& x);
0054 
0055 // recip(x) liefert (/ x), wo x eine Zahl ist.
0056 extern const cl_N recip (const cl_N& x);
0057 
0058 // (1+ x), wo x eine Zahl ist.
0059 extern const cl_N plus1 (const cl_N& x);
0060 
0061 // (1- x), wo x eine Zahl ist.
0062 extern const cl_N minus1 (const cl_N& x);
0063 
0064 // signum(x) liefert (signum x), wo x eine Zahl ist.
0065 extern const cl_N signum (const cl_N& x);
0066 
0067 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer Zahl x.
0068 extern const cl_N sqrt (const cl_N& x);
0069 
0070 // equal(x,y) vergleicht zwei Zahlen x und y auf Gleichheit.
0071 extern bool equal (const cl_N& x, const cl_N& y);
0072 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
0073 extern uint32 equal_hashcode (const cl_N& x);
0074 
0075 inline bool operator== (const cl_N& x, const cl_N& y)
0076         { return equal(x,y); }
0077 inline bool operator!= (const cl_N& x, const cl_N& y)
0078         { return !equal(x,y); }
0079 
0080 // phase(x) liefert (phase x), wo x eine Zahl ist.
0081 // Ergebnis rational nur wenn (= x 0) oder wenn x reell und >0.
0082 extern const cl_R phase (const cl_N& x);
0083 
0084 // exp(x) liefert (exp x), wo x eine Zahl ist.
0085 extern const cl_N exp (const cl_N& x);
0086 
0087 // log(x) liefert (log x), wo x eine Zahl ist.
0088 extern const cl_N log (const cl_N& x);
0089 
0090 // log(a,b) liefert (log a b), wo a und b Zahlen sind.
0091 extern const cl_N log (const cl_N& a, const cl_N& b);
0092 
0093 // (expt x y), wo x eine Zahl und y ein Integer ist.
0094 extern const cl_N expt (const cl_N& x, sintL y);
0095 extern const cl_N expt (const cl_N& x, const cl_I& y);
0096 
0097 // (expt x y), wo x und y Zahlen sind.
0098 extern const cl_N expt (const cl_N& x, const cl_N& y);
0099 
0100 // sin(x) liefert (sin x), wo x eine Zahl ist.
0101 extern const cl_N sin (const cl_N& x);
0102 
0103 // cos(x) liefert (cos x), wo x eine Zahl ist.
0104 extern const cl_N cos (const cl_N& x);
0105 
0106 // tan(x) liefert (tan x), wo x eine Zahl ist.
0107 extern const cl_N tan (const cl_N& x);
0108 
0109 // cis(x) liefert (cis x), wo x eine Zahl ist.
0110 extern const cl_N cis (const cl_R& x);
0111 extern const cl_N cis (const cl_N& x);
0112 
0113 // sinh(x) liefert (sinh x), wo x eine Zahl ist.
0114 extern const cl_N sinh (const cl_N& x);
0115 
0116 // cosh(x) liefert (cosh x), wo x eine Zahl ist.
0117 extern const cl_N cosh (const cl_N& x);
0118 
0119 // tanh(x) liefert (tanh x), wo x eine Zahl ist.
0120 extern const cl_N tanh (const cl_N& x);
0121 
0122 // atan(z) liefert den Arctan einer Zahl z.
0123 extern const cl_N atan (const cl_N& z);
0124 
0125 // atanh(z) liefert den Artanh einer Zahl z.
0126 extern const cl_N atanh (const cl_N& z);
0127 
0128 // asin(z) liefert den Arcsin einer Zahl z.
0129 extern const cl_N asin (const cl_N& z);
0130 
0131 // asinh(z) liefert den Arsinh einer Zahl z.
0132 extern const cl_N asinh (const cl_N& z);
0133 
0134 // acos(z) liefert den Arccos einer Zahl z.
0135 extern const cl_N acos (const cl_N& z);
0136 
0137 // acosh(z) liefert den Arcosh einer Zahl z.
0138 extern const cl_N acosh (const cl_N& z);
0139 
0140 
0141 // This could be optimized to use in-place operations.
0142 inline cl_N& operator+= (cl_N& x, const cl_N& y) { return x = x + y; }
0143 inline cl_N& operator++ /* prefix */ (cl_N& x) { return x = plus1(x); }
0144 inline void operator++ /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = plus1(x); }
0145 inline cl_N& operator-= (cl_N& x, const cl_N& y) { return x = x - y; }
0146 inline cl_N& operator-- /* prefix */ (cl_N& x) { return x = minus1(x); }
0147 inline void operator-- /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = minus1(x); }
0148 inline cl_N& operator*= (cl_N& x, const cl_N& y) { return x = x * y; }
0149 inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; }
0150 
0151 
0152 // Runtime typing support.
0153 extern cl_class cl_class_complex;
0154 
0155 }  // namespace cln
0156 
0157 #endif /* _CL_COMPLEX_H */