]> www.ginac.de Git - cln.git/blob - src/complex/transcendental/cl_C_phase.cc
Initial revision
[cln.git] / src / complex / transcendental / cl_C_phase.cc
1 // phase().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cl_real.h"
14
15 const cl_R phase (const cl_N& x)
16 {
17 // Methode:
18 // (= x 0) -> willkürliches Ergebnis 0
19 // x reell -> Winkel von (x,0) in Polarkoordinaten
20 // x komplex -> Winkel von ((realpart x),(imagpart x)) in Polarkoordinaten
21         if (zerop(x))
22                 return 0;
23         if (realp(x)) {
24                 DeclareType(cl_R,x);
25                 return atan(x,0);
26         } else {
27                 DeclareType(cl_C,x);
28                 return atan(realpart(x),imagpart(x));
29         }
30 }