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