flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
log.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef LOG_H
20#define LOG_H
21
22#include <cmath>
23#include <complex>
24
25namespace flexiblesusy {
26
27
29template <typename T>
30std::complex<T> log1p(const std::complex<T>& z) noexcept
31{
32 const std::complex<T> u = T(1) + z;
33
34 if (std::real(u) == T(1) && std::imag(u) == T(0)) {
35 return z;
36 } else if (std::real(u) <= T(0)) {
37 return std::log(u);
38 }
39
40 return std::log(u)*(z/(u - T(1)));
41}
42
43
51template <typename T>
52std::complex<T> pos_log(const std::complex<T>& z) noexcept
53{
54 if (std::imag(z) == T(0) && std::real(z) > T(0)) {
55 return { std::log(std::real(z)), T(0) };
56 } else if (std::imag(z) == T(0)) {
57 return { std::log(-std::real(z)), 4*std::atan(T(1)) };
58 }
59
60 return std::log(z);
61}
62
63
64} // namespace flexiblesusy
65
66#endif
std::complex< T > log1p(const std::complex< T > &z) noexcept
returns log(1 + z) for complex z
Definition log.hpp:30
std::complex< T > pos_log(const std::complex< T > &z) noexcept
Definition log.hpp:52