]> www.ginac.de Git - cln.git/blob - include/cln/complex.h
* include/cln/number.h, cl_number::_as_cl_private_thing(): removed.
[cln.git] / include / cln / complex.h
1 // Public complex number operations.
2
3 #ifndef _CL_COMPLEX_H
4 #define _CL_COMPLEX_H
5
6 #include "cln/number.h"
7 #include "cln/complex_class.h"
8 #include "cln/real_class.h"
9 #include "cln/integer_class.h"
10
11 namespace cln {
12
13 CL_DEFINE_AS_CONVERSION(cl_N)
14
15
16 // zerop(x) testet, ob (= x 0).
17 extern cl_boolean zerop (const cl_N& x);
18
19
20 // Liefert zu reellen Zahlen a und b die komplexe Zahl a+bi.
21 // complex(a,b)
22 extern const cl_N complex (const cl_R& a, const cl_R& b);
23
24 // realpart(x) liefert den Realteil der Zahl x.
25 extern const cl_R realpart (const cl_N& x);
26
27 // imagpart(x) liefert den Imaginärteil der Zahl x.
28 extern const cl_R imagpart (const cl_N& x);
29
30 // conjugate(x) liefert die konjugiert komplexe Zahl zur Zahl x.
31 extern const cl_N conjugate (const cl_N& x);
32
33
34 // Liefert (- x), wo x eine Zahl ist.
35 extern const cl_N operator- (const cl_N& x);
36
37 // Liefert (+ x y), wo x und y Zahlen sind.
38 extern const cl_N operator+ (const cl_N& x, const cl_N& y);
39
40 // Liefert (- x y), wo x und y Zahlen sind.
41 extern const cl_N operator- (const cl_N& x, const cl_N& y);
42
43 // Liefert (* x y), wo x und y Zahlen sind.
44 extern const cl_N operator* (const cl_N& x, const cl_N& y);
45
46 // Liefert (* x x), wo x eine Zahl ist.
47 extern const cl_N square (const cl_N& x);
48
49 // Liefert (/ x y), wo x und y Zahlen sind.
50 extern const cl_N operator/ (const cl_N& x, const cl_N& y);
51
52 // Liefert (abs x), wo x eine Zahl ist.
53 extern const cl_R abs (const cl_N& x);
54
55 // recip(x) liefert (/ x), wo x eine Zahl ist.
56 extern const cl_N recip (const cl_N& x);
57
58 // (1+ x), wo x eine Zahl ist.
59 extern const cl_N plus1 (const cl_N& x);
60
61 // (1- x), wo x eine Zahl ist.
62 extern const cl_N minus1 (const cl_N& x);
63
64 // signum(x) liefert (signum x), wo x eine Zahl ist.
65 extern const cl_N signum (const cl_N& x);
66
67 // sqrt(x) = (sqrt x) zieht die Wurzel aus einer Zahl x.
68 extern const cl_N sqrt (const cl_N& x);
69
70 // equal(x,y) vergleicht zwei Zahlen x und y auf Gleichheit.
71 extern cl_boolean equal (const cl_N& x, const cl_N& y);
72 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
73 extern uint32 equal_hashcode (const cl_N& x);
74
75 inline bool operator== (const cl_N& x, const cl_N& y)
76         { return equal(x,y); }
77 inline bool operator!= (const cl_N& x, const cl_N& y)
78         { return !equal(x,y); }
79
80 // phase(x) liefert (phase x), wo x eine Zahl ist.
81 // Ergebnis rational nur wenn (= x 0) oder wenn x reell und >0.
82 extern const cl_R phase (const cl_N& x);
83
84 // exp(x) liefert (exp x), wo x eine Zahl ist.
85 extern const cl_N exp (const cl_N& x);
86
87 // log(x) liefert (log x), wo x eine Zahl ist.
88 extern const cl_N log (const cl_N& x);
89
90 // log(a,b) liefert (log a b), wo a und b Zahlen sind.
91 extern const cl_N log (const cl_N& a, const cl_N& b);
92
93 // (expt x y), wo x eine Zahl und y ein Integer ist.
94 extern const cl_N expt (const cl_N& x, sintL y);
95 extern const cl_N expt (const cl_N& x, const cl_I& y);
96
97 // (expt x y), wo x und y Zahlen sind.
98 extern const cl_N expt (const cl_N& x, const cl_N& y);
99
100 // sin(x) liefert (sin x), wo x eine Zahl ist.
101 extern const cl_N sin (const cl_N& x);
102
103 // cos(x) liefert (cos x), wo x eine Zahl ist.
104 extern const cl_N cos (const cl_N& x);
105
106 // tan(x) liefert (tan x), wo x eine Zahl ist.
107 extern const cl_N tan (const cl_N& x);
108
109 // cis(x) liefert (cis x), wo x eine Zahl ist.
110 extern const cl_N cis (const cl_R& x);
111 extern const cl_N cis (const cl_N& x);
112
113 // sinh(x) liefert (sinh x), wo x eine Zahl ist.
114 extern const cl_N sinh (const cl_N& x);
115
116 // cosh(x) liefert (cosh x), wo x eine Zahl ist.
117 extern const cl_N cosh (const cl_N& x);
118
119 // tanh(x) liefert (tanh x), wo x eine Zahl ist.
120 extern const cl_N tanh (const cl_N& x);
121
122 // atan(z) liefert den Arctan einer Zahl z.
123 extern const cl_N atan (const cl_N& z);
124
125 // atanh(z) liefert den Artanh einer Zahl z.
126 extern const cl_N atanh (const cl_N& z);
127
128 // asin(z) liefert den Arcsin einer Zahl z.
129 extern const cl_N asin (const cl_N& z);
130
131 // asinh(z) liefert den Arsinh einer Zahl z.
132 extern const cl_N asinh (const cl_N& z);
133
134 // acos(z) liefert den Arccos einer Zahl z.
135 extern const cl_N acos (const cl_N& z);
136
137 // acosh(z) liefert den Arcosh einer Zahl z.
138 extern const cl_N acosh (const cl_N& z);
139
140
141 #ifdef WANT_OBFUSCATING_OPERATORS
142 // This could be optimized to use in-place operations.
143 inline cl_N& operator+= (cl_N& x, const cl_N& y) { return x = x + y; }
144 inline cl_N& operator++ /* prefix */ (cl_N& x) { return x = plus1(x); }
145 inline void operator++ /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = plus1(x); }
146 inline cl_N& operator-= (cl_N& x, const cl_N& y) { return x = x - y; }
147 inline cl_N& operator-- /* prefix */ (cl_N& x) { return x = minus1(x); }
148 inline void operator-- /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = minus1(x); }
149 inline cl_N& operator*= (cl_N& x, const cl_N& y) { return x = x * y; }
150 inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; }
151 #endif
152
153
154 // Runtime typing support.
155 extern cl_class cl_class_complex;
156
157 }  // namespace cln
158
159 #endif /* _CL_COMPLEX_H */