]> www.ginac.de Git - cln.git/blob - src/complex/transcendental/cl_C_phase.cc
cce43cb2f4aa97729aab8cc06d40021ede1f1011
[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 "cln/complex.h"
8
9
10 // Implementation.
11
12 #include "cl_C.h"
13 #include "cln/real.h"
14
15 namespace cln {
16
17 const cl_R phase (const cl_N& x)
18 {
19 // Methode:
20 // (= x 0) -> willkürliches Ergebnis 0
21 // x reell -> Winkel von (x,0) in Polarkoordinaten
22 // x komplex -> Winkel von ((realpart x),(imagpart x)) in Polarkoordinaten
23         if (zerop(x))
24                 return 0;
25         if (realp(x)) {
26                 DeclareType(cl_R,x);
27                 return atan(x,0);
28         } else {
29                 DeclareType(cl_C,x);
30                 return atan(realpart(x),imagpart(x));
31         }
32 }
33
34 }  // namespace cln