Skip to content

Commit

Permalink
Changing input argument to match gcc (k vs m). Updated documentation …
Browse files Browse the repository at this point in the history
…to mention that it is an argument of k.
  • Loading branch information
clarkse committed Sep 17, 2024
1 parent 093a2cc commit f77df48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Docs/sphinx_documentation/source/Basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ numbers can be computed with ``min`` and ``max``, respectively. It supports
the Heaviside step function, ``heaviside(x1,x2)`` that gives ``0``, ``x2``,
``1``, for ``x1 < 0``, ``x1 = 0`` and ``x1 > 0``, respectively.
It supports the Bessel function of the first kind of order ``n``
``jn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1`` and ``comp_ellint_2``,
``jn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1(k)`` and ``comp_ellint_2(k)``,
are supported.
There is ``if(a,b,c)`` that gives ``b`` or ``c`` depending on the value of
``a``. A number of comparison operators are supported, including ``<``,
Expand Down
17 changes: 12 additions & 5 deletions Src/Base/AMReX_Math.H
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,17 @@ std::uint64_t umulhi (std::uint64_t a, std::uint64_t b)

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T comp_ellint_1 (T m)
T comp_ellint_1 (T k)
{
// Computing K based on DLMF
// https://dlmf.nist.gov/19.8
T tol = 1e-12;
if constexpr (std::is_same<T, float>::value) {
tol = 1e-6;
}

T a0 = 1.0;
T g0 = std::sqrt(1.0 - m);
T g0 = std::sqrt(1.0 - k*k);
T a, g;

// Find Arithmetic Geometric mean
Expand All @@ -251,16 +255,19 @@ T comp_ellint_1 (T m)

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
T comp_ellint_2 (T m)
T comp_ellint_2 (T k)
{
// Computing E based on DLMF
// https://dlmf.nist.gov/19.8
T Kcomp = amrex::Math::comp_ellint_1<T>(m);
T Kcomp = amrex::Math::comp_ellint_1<T>(k);
T tol = 1e-12;
if constexpr (std::is_same<T, float>::value) {
tol = 1e-6;
}

// Step Zero
T a0 = 1.0;
T g0 = std::sqrt(1.0 - m);
T g0 = std::sqrt(1.0 - k*k);
T cn = std::sqrt(a0*a0 - g0*g0);

// Step 1
Expand Down

0 comments on commit f77df48

Please sign in to comment.