# DEAL_II_HAVE_FP_EXCEPTIONS
# DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
# DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
+# DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS
# DEAL_II_FALLTHROUGH
# DEAL_II_DEPRECATED
# DEAL_II_CONSTEXPR
DEAL_II_HAVE_CXX17_ATTRIBUTE_FALLTHROUGH
DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
+ DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS
DEAL_II_CXX14_CONSTEXPR_BUG_OK
)
#
-# Check for c++17 bessel function support. Unfortunately libc++ version 10
+# Check for c++17 Bessel function support. Unfortunately libc++ version 10
# does not have those.
#
)
+#
+# Check for c++17 Legendre function support.
+#
+
+CHECK_CXX_SOURCE_COMPILES(
+ "
+ #include <cmath>
+ using std::legendre;
+ using std::legendref;
+ using std::legendrel;
+ int main()
+ {
+ }
+ "
+ DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS
+ )
+
+
#
# Check for correct c++14 constexpr support.
#
#include <deal.II/base/config.h>
-#ifdef DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
+#if defined(DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS) || \
+ defined(DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS)
# include <cmath>
-#else
+#endif
+
+#ifndef DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
# include <boost/math/special_functions/bessel.hpp>
#endif
+#ifndef DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS
+# include <deal.II/base/exceptions.h>
+
+# include <boost/math/special_functions/legendre.hpp>
+
+# include <limits>
+#endif
+
DEAL_II_NAMESPACE_OPEN
+
namespace std_cxx17
{
#ifndef DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
inline double
- cyl_bessel_j(double x, double y)
+ cyl_bessel_j(double nu, double x)
{
- return boost::math::cyl_bessel_j(x, y);
+ return boost::math::cyl_bessel_j(nu, x);
}
inline float
- cyl_bessel_jf(float x, float y)
+ cyl_bessel_jf(float nu, float x)
{
- return boost::math::cyl_bessel_j(x, y);
+ return boost::math::cyl_bessel_j(nu, x);
}
inline long double
- cyl_bessel_jl(long double x, long double y)
+ cyl_bessel_jl(long double nu, long double x)
{
- return boost::math::cyl_bessel_j(x, y);
+ return boost::math::cyl_bessel_j(nu, x);
}
#else
using std::cyl_bessel_jf;
using std::cyl_bessel_jl;
#endif
+
+#ifndef DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS
+
+ inline double
+ legendre(unsigned int l, double x)
+ {
+ Assert(static_cast<int>(l) >= 0,
+ ExcIndexRange(l, 0, std::numeric_limits<int>::max()));
+ return boost::math::legendre_p(static_cast<int>(l), x);
+ }
+
+
+
+ inline float
+ legendre(unsigned int l, float x)
+ {
+ Assert(static_cast<int>(l) >= 0,
+ ExcIndexRange(l, 0, std::numeric_limits<int>::max()));
+ return boost::math::legendre_p(static_cast<int>(l), x);
+ }
+
+
+
+ inline long double
+ legendre(unsigned int l, long double x)
+ {
+ Assert(static_cast<int>(l) >= 0,
+ ExcIndexRange(l, 0, std::numeric_limits<int>::max()));
+ return boost::math::legendre_p(static_cast<int>(l), x);
+ }
+
+
+
+ inline float
+ legendref(unsigned int l, float x)
+ {
+ Assert(static_cast<int>(l) >= 0,
+ ExcIndexRange(l, 0, std::numeric_limits<int>::max()));
+ return boost::math::legendre_p(static_cast<int>(l), x);
+ }
+
+
+
+ inline long double
+ legendrel(unsigned int l, long double x)
+ {
+ Assert(static_cast<int>(l) >= 0,
+ ExcIndexRange(l, 0, std::numeric_limits<int>::max()));
+ return boost::math::legendre_p(static_cast<int>(l), x);
+ }
+
+#else
+ using std::legendre;
+ using std::legendref;
+ using std::legendrel;
+#endif
} // namespace std_cxx17
+
+
DEAL_II_NAMESPACE_CLOSE
#endif // dealii_cxx17_cmath_h
+#include <deal.II/base/std_cxx17/cmath.h>
#include <deal.II/base/thread_management.h>
#include <deal.II/fe/fe_series.h>
#include <iostream>
-#ifdef DEAL_II_WITH_GSL
-# include <gsl/gsl_sf_legendre.h>
-#endif
DEAL_II_NAMESPACE_OPEN
double
Lh(const Point<dim> &x_q, const TableIndices<dim> &indices)
{
-#ifdef DEAL_II_WITH_GSL
double res = 1.0;
for (unsigned int d = 0; d < dim; d++)
{
const double x = 2.0 * (x_q[d] - 0.5);
Assert((x_q[d] <= 1.0) && (x_q[d] >= 0.), ExcLegendre(d, x_q[d]));
- const int ind = indices[d];
- res *= std::sqrt(2.0) * gsl_sf_legendre_Pl(ind, x);
+ const unsigned int ind = indices[d];
+ res *= std::sqrt(2.0) * std_cxx17::legendre(ind, x);
}
return res;
-
-#else
-
- (void)x_q;
- (void)indices;
- AssertThrow(false,
- ExcMessage("deal.II has to be configured with GSL "
- "in order to use Legendre transformation."));
- return 0;
-#endif
}