]> www.ginac.de Git - cln.git/blob - src/complex/algebraic/cl_C_signum.cc
* src/complex/transcendental/cl_C_expt_C.cc (expt): fix logic for
[cln.git] / src / complex / algebraic / cl_C_signum.cc
1 // signum().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cln/real.h"
14
15 #undef MAYBE_INLINE
16 #define MAYBE_INLINE inline
17 #include "cl_C_abs_aux.cc"
18
19 namespace cln {
20
21 const cl_N signum (const cl_N& x)
22 {
23 // Methode:
24 // x reell -> klar.
25 // x komplex -> falls (zerop x), x als Ergebnis, sonst (/ x (abs x)).
26         if (realp(x)) {
27                 DeclareType(cl_R,x);
28                 return signum(x);
29         } else {
30                 DeclareType(cl_C,x);
31                 if (zerop(x))
32                         return x;
33                 else
34                         return x / abs(x);
35         }
36 }
37
38 }  // namespace cln