PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/cln-1.3.2/src/complex/transcendental/cl_C_atan.cc

#
C++ | 43 lines | 23 code | 10 blank | 10 comment | 2 complexity | 050f7f7440e30e97cf49525d23d63211 MD5 | raw file
Possible License(s): GPL-2.0
 1// atan().
 2
 3// General includes.
 4#include "base/cl_sysdep.h"
 5
 6// Specification.
 7#include "cln/complex.h"
 8
 9
10// Implementation.
11
12#include "complex/cl_C.h"
13#include "cln/real.h"
14
15namespace cln {
16
17// Methode:
18// Wert und Branch Cuts nach der Formel CLTL2, S. 307/312/313:
19//   arctan(z) = (log(1+iz)-log(1-iz)) / 2i
20// Sei z=x+iy, errechne u+iv = artanh(-y+ix) wie oben, Ergebnis v-iu.
21// Real- und Imaginärteil des Ergebnisses sind Floats, außer wenn z reell oder
22// rein imaginär ist.
23
24inline const cl_C_R _atan (const cl_N& z)
25{
26	if (realp(z)) {
27		DeclareType(cl_R,z);
28		return atanh(0,z);
29	} else {
30		DeclareType(cl_C,z);
31		return atanh(-imagpart(z),realpart(z));
32	}
33}
34
35const cl_N atan (const cl_N& z)
36{
37	var cl_C_R u_v = _atan(z);
38	var cl_R& u = u_v.realpart;
39	var cl_R& v = u_v.imagpart;
40	return complex(v,-u); // v-iu
41}
42
43}  // namespace cln