Skip to content

Commit f77df48

Browse files
committed
Changing input argument to match gcc (k vs m). Updated documentation to mention that it is an argument of k.
1 parent 093a2cc commit f77df48

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Docs/sphinx_documentation/source/Basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ numbers can be computed with ``min`` and ``max``, respectively. It supports
595595
the Heaviside step function, ``heaviside(x1,x2)`` that gives ``0``, ``x2``,
596596
``1``, for ``x1 < 0``, ``x1 = 0`` and ``x1 > 0``, respectively.
597597
It supports the Bessel function of the first kind of order ``n``
598-
``jn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1`` and ``comp_ellint_2``,
598+
``jn(n,x)``. Complete elliptic integrals of the first and second kind, ``comp_ellint_1(k)`` and ``comp_ellint_2(k)``,
599599
are supported.
600600
There is ``if(a,b,c)`` that gives ``b`` or ``c`` depending on the value of
601601
``a``. A number of comparison operators are supported, including ``<``,

Src/Base/AMReX_Math.H

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,17 @@ std::uint64_t umulhi (std::uint64_t a, std::uint64_t b)
228228

229229
template <typename T>
230230
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
231-
T comp_ellint_1 (T m)
231+
T comp_ellint_1 (T k)
232232
{
233233
// Computing K based on DLMF
234234
// https://dlmf.nist.gov/19.8
235235
T tol = 1e-12;
236+
if constexpr (std::is_same<T, float>::value) {
237+
tol = 1e-6;
238+
}
239+
236240
T a0 = 1.0;
237-
T g0 = std::sqrt(1.0 - m);
241+
T g0 = std::sqrt(1.0 - k*k);
238242
T a, g;
239243

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

252256
template <typename T>
253257
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
254-
T comp_ellint_2 (T m)
258+
T comp_ellint_2 (T k)
255259
{
256260
// Computing E based on DLMF
257261
// https://dlmf.nist.gov/19.8
258-
T Kcomp = amrex::Math::comp_ellint_1<T>(m);
262+
T Kcomp = amrex::Math::comp_ellint_1<T>(k);
259263
T tol = 1e-12;
264+
if constexpr (std::is_same<T, float>::value) {
265+
tol = 1e-6;
266+
}
260267

261268
// Step Zero
262269
T a0 = 1.0;
263-
T g0 = std::sqrt(1.0 - m);
270+
T g0 = std::sqrt(1.0 - k*k);
264271
T cn = std::sqrt(a0*a0 - g0*g0);
265272

266273
// Step 1

0 commit comments

Comments
 (0)