Skip to content

Commit

Permalink
use std::norm
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Mar 14, 2024
1 parent d8da940 commit fffee02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/cpp/Li2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ std::complex<float> Li2(const std::complex<float>& z) noexcept
return { Li2(rz), -PI*std::log(rz) };
}

const float nz = rz*rz + iz*iz;
const float nz = std::norm(z);

if (nz < std::numeric_limits<float>::epsilon()) {
return z*(1.0f + 0.25f*z);
Expand Down Expand Up @@ -391,7 +391,7 @@ std::complex<double> Li2(const std::complex<double>& z) noexcept
return { Li2(rz), -PI*std::log(rz) };
}

const double nz = rz*rz + iz*iz;
const double nz = std::norm(z);

if (nz < std::numeric_limits<double>::epsilon()) {
return z*(1.0 + 0.25*z);
Expand Down Expand Up @@ -484,7 +484,7 @@ std::complex<long double> Li2(const std::complex<long double>& z) noexcept
return { Li2(rz), -PI*std::log(rz) };
}

const long double nz = rz*rz + iz*iz;
const long double nz = std::norm(z);

if (nz < std::numeric_limits<long double>::epsilon()) {
return z*(1.0L + 0.25L*z);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/horner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::complex<T> horner(const std::complex<T>& z, const T (&coeffs)[N]) noexcept
const T rz = std::real(z);
const T iz = std::imag(z);
const T r = rz + rz;
const T s = rz*rz + iz*iz;
const T s = std::norm(z);
T a = coeffs[N - 1], b = coeffs[N - 2];

for (int i = N - 3; i >= Nstart; --i) {
Expand Down

0 comments on commit fffee02

Please sign in to comment.