Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Bessel functions of second kind (yn) #4234

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(k)`` and ``comp_ellint_2(k)``,
``jn(n,x)``, and the Bessel function of the second kind of order ``n`` ``yn(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
19 changes: 19 additions & 0 deletions Src/Base/Parser/AMReX_Parser_Y.H
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum parser_f2_t { // Built-in functions with two arguments
PARSER_OR,
PARSER_HEAVISIDE,
PARSER_JN,
PARSER_YN,
PARSER_MIN,
PARSER_MAX,
PARSER_FMOD
Expand All @@ -116,6 +117,7 @@ std::string_view parser_f2_s[] =
"or",
"heaviside",
"jn",
"yn",
"min",
"max",
"fmod"
Expand Down Expand Up @@ -400,6 +402,21 @@ T parser_math_jn (int a, T b)
#endif
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE
T parser_math_yn (int a, T b)
{
#if defined AMREX_USE_SYCL || defined __MINGW32__
amrex::ignore_unused(a,b);
// neither yn(f) nor std::cyl_bessel_y work yet
// https://github.com/oneapi-src/oneAPI-spec/issues/308
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(false, "parser: yn in SYCL not supported yet");
return 0.0;
#else
return yn(a, b);
#endif
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double
parser_call_f1 (enum parser_f1_t type, double a)
{
Expand Down Expand Up @@ -460,6 +477,8 @@ parser_call_f2 (enum parser_f2_t type, double a, double b)
return (a < 0.0) ? 0.0 : ((a > 0.0) ? 1.0 : b);
case PARSER_JN:
return parser_math_jn<double>(int(a),b);
case PARSER_YN:
return parser_math_yn<double>(int(a),b);
case PARSER_MIN:
return (a < b) ? a : b;
case PARSER_MAX:
Expand Down
1 change: 1 addition & 0 deletions Src/Base/Parser/amrex_parser.l
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ EXP ([Ee][-+]?[0-9]+)
"pow" { amrex_parserlval.f2 = amrex::PARSER_POW; return F2; }
"heaviside" { amrex_parserlval.f2 = amrex::PARSER_HEAVISIDE; return F2; }
"jn" { amrex_parserlval.f2 = amrex::PARSER_JN; return F2; }
"yn" { amrex_parserlval.f2 = amrex::PARSER_YN; return F2; }
"min" { amrex_parserlval.f2 = amrex::PARSER_MIN; return F2; }
"max" { amrex_parserlval.f2 = amrex::PARSER_MAX; return F2; }
"fmod" { amrex_parserlval.f2 = amrex::PARSER_FMOD; return F2; }
Expand Down
Loading
Loading