PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms 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. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/complex.h"
  6. // Implementation.
  7. #include "complex/cl_C.h"
  8. #include "cln/real.h"
  9. namespace cln {
  10. // Methode:
  11. // Wert und Branch Cuts nach der Formel CLTL2, S. 307/312/313:
  12. // arctan(z) = (log(1+iz)-log(1-iz)) / 2i
  13. // Sei z=x+iy, errechne u+iv = artanh(-y+ix) wie oben, Ergebnis v-iu.
  14. // Real- und Imaginärteil des Ergebnisses sind Floats, außer wenn z reell oder
  15. // rein imaginär ist.
  16. inline const cl_C_R _atan (const cl_N& z)
  17. {
  18. if (realp(z)) {
  19. DeclareType(cl_R,z);
  20. return atanh(0,z);
  21. } else {
  22. DeclareType(cl_C,z);
  23. return atanh(-imagpart(z),realpart(z));
  24. }
  25. }
  26. const cl_N atan (const cl_N& z)
  27. {
  28. var cl_C_R u_v = _atan(z);
  29. var cl_R& u = u_v.realpart;
  30. var cl_R& v = u_v.imagpart;
  31. return complex(v,-u); // v-iu
  32. }
  33. } // namespace cln