159 lines
4.8 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Public complex number operations.
  2. #ifndef _CL_COMPLEX_H
  3. #define _CL_COMPLEX_H
  4. #include "cln/number.h"
  5. #include "cln/complex_class.h"
  6. #include "cln/real_class.h"
  7. #include "cln/integer_class.h"
  8. namespace cln {
  9. CL_DEFINE_AS_CONVERSION(cl_N)
  10. // zerop(x) testet, ob (= x 0).
  11. extern cl_boolean zerop (const cl_N& x);
  12. // Liefert zu reellen Zahlen a und b die komplexe Zahl a+bi.
  13. // complex(a,b)
  14. extern const cl_N complex (const cl_R& a, const cl_R& b);
  15. // realpart(x) liefert den Realteil der Zahl x.
  16. extern const cl_R realpart (const cl_N& x);
  17. // imagpart(x) liefert den Imagin�rteil der Zahl x.
  18. extern const cl_R imagpart (const cl_N& x);
  19. // conjugate(x) liefert die konjugiert komplexe Zahl zur Zahl x.
  20. extern const cl_N conjugate (const cl_N& x);
  21. // Liefert (- x), wo x eine Zahl ist.
  22. extern const cl_N operator- (const cl_N& x);
  23. // Liefert (+ x y), wo x und y Zahlen sind.
  24. extern const cl_N operator+ (const cl_N& x, const cl_N& y);
  25. // Liefert (- x y), wo x und y Zahlen sind.
  26. extern const cl_N operator- (const cl_N& x, const cl_N& y);
  27. // Liefert (* x y), wo x und y Zahlen sind.
  28. extern const cl_N operator* (const cl_N& x, const cl_N& y);
  29. // Liefert (* x x), wo x eine Zahl ist.
  30. extern const cl_N square (const cl_N& x);
  31. // Liefert (/ x y), wo x und y Zahlen sind.
  32. extern const cl_N operator/ (const cl_N& x, const cl_N& y);
  33. // Liefert (abs x), wo x eine Zahl ist.
  34. extern const cl_R abs (const cl_N& x);
  35. // recip(x) liefert (/ x), wo x eine Zahl ist.
  36. extern const cl_N recip (const cl_N& x);
  37. // (1+ x), wo x eine Zahl ist.
  38. extern const cl_N plus1 (const cl_N& x);
  39. // (1- x), wo x eine Zahl ist.
  40. extern const cl_N minus1 (const cl_N& x);
  41. // signum(x) liefert (signum x), wo x eine Zahl ist.
  42. extern const cl_N signum (const cl_N& x);
  43. // sqrt(x) = (sqrt x) zieht die Wurzel aus einer Zahl x.
  44. extern const cl_N sqrt (const cl_N& x);
  45. // equal(x,y) vergleicht zwei Zahlen x und y auf Gleichheit.
  46. extern cl_boolean equal (const cl_N& x, const cl_N& y);
  47. // equal_hashcode(x) liefert einen equal-invarianten Hashcode f�r x.
  48. extern uint32 equal_hashcode (const cl_N& x);
  49. inline bool operator== (const cl_N& x, const cl_N& y)
  50. { return equal(x,y); }
  51. inline bool operator!= (const cl_N& x, const cl_N& y)
  52. { return !equal(x,y); }
  53. // phase(x) liefert (phase x), wo x eine Zahl ist.
  54. // Ergebnis rational nur wenn (= x 0) oder wenn x reell und >0.
  55. extern const cl_R phase (const cl_N& x);
  56. // exp(x) liefert (exp x), wo x eine Zahl ist.
  57. extern const cl_N exp (const cl_N& x);
  58. // log(x) liefert (log x), wo x eine Zahl ist.
  59. extern const cl_N log (const cl_N& x);
  60. // log(a,b) liefert (log a b), wo a und b Zahlen sind.
  61. extern const cl_N log (const cl_N& a, const cl_N& b);
  62. // (expt x y), wo x eine Zahl und y ein Integer ist.
  63. extern const cl_N expt (const cl_N& x, sintL y);
  64. extern const cl_N expt (const cl_N& x, const cl_I& y);
  65. // (expt x y), wo x und y Zahlen sind.
  66. extern const cl_N expt (const cl_N& x, const cl_N& y);
  67. // sin(x) liefert (sin x), wo x eine Zahl ist.
  68. extern const cl_N sin (const cl_N& x);
  69. // cos(x) liefert (cos x), wo x eine Zahl ist.
  70. extern const cl_N cos (const cl_N& x);
  71. // tan(x) liefert (tan x), wo x eine Zahl ist.
  72. extern const cl_N tan (const cl_N& x);
  73. // cis(x) liefert (cis x), wo x eine Zahl ist.
  74. extern const cl_N cis (const cl_R& x);
  75. extern const cl_N cis (const cl_N& x);
  76. // sinh(x) liefert (sinh x), wo x eine Zahl ist.
  77. extern const cl_N sinh (const cl_N& x);
  78. // cosh(x) liefert (cosh x), wo x eine Zahl ist.
  79. extern const cl_N cosh (const cl_N& x);
  80. // tanh(x) liefert (tanh x), wo x eine Zahl ist.
  81. extern const cl_N tanh (const cl_N& x);
  82. // atan(z) liefert den Arctan einer Zahl z.
  83. extern const cl_N atan (const cl_N& z);
  84. // atanh(z) liefert den Artanh einer Zahl z.
  85. extern const cl_N atanh (const cl_N& z);
  86. // asin(z) liefert den Arcsin einer Zahl z.
  87. extern const cl_N asin (const cl_N& z);
  88. // asinh(z) liefert den Arsinh einer Zahl z.
  89. extern const cl_N asinh (const cl_N& z);
  90. // acos(z) liefert den Arccos einer Zahl z.
  91. extern const cl_N acos (const cl_N& z);
  92. // acosh(z) liefert den Arcosh einer Zahl z.
  93. extern const cl_N acosh (const cl_N& z);
  94. #ifdef WANT_OBFUSCATING_OPERATORS
  95. // This could be optimized to use in-place operations.
  96. inline cl_N& operator+= (cl_N& x, const cl_N& y) { return x = x + y; }
  97. inline cl_N& operator++ /* prefix */ (cl_N& x) { return x = plus1(x); }
  98. inline void operator++ /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = plus1(x); }
  99. inline cl_N& operator-= (cl_N& x, const cl_N& y) { return x = x - y; }
  100. inline cl_N& operator-- /* prefix */ (cl_N& x) { return x = minus1(x); }
  101. inline void operator-- /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = minus1(x); }
  102. inline cl_N& operator*= (cl_N& x, const cl_N& y) { return x = x * y; }
  103. inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; }
  104. #endif
  105. // Runtime typing support.
  106. extern cl_class cl_class_complex;
  107. } // namespace cln
  108. #endif /* _CL_COMPLEX_H */