From e38dd48a27b59b59a924b66a9486c3c2856acdf9 Mon Sep 17 00:00:00 2001 From: Srinivas Vasudevan Date: Mon, 12 Aug 2019 19:26:29 -0400 Subject: PR 681: Add ndtri function, the inverse of the normal distribution function. --- Eigen/src/Core/arch/AVX/PacketMath.h | 1 + Eigen/src/Core/arch/AVX512/PacketMath.h | 1 + .../Core/arch/Default/GenericPacketMathFunctions.h | 55 ++++++++++++++++++++++ Eigen/src/Core/arch/GPU/PacketMath.h | 2 + Eigen/src/Core/arch/SSE/PacketMath.h | 1 + Eigen/src/Core/arch/SYCL/InteropHeaders.h | 1 + 6 files changed, 61 insertions(+) (limited to 'Eigen/src/Core/arch') diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h index 020f6c276..e3363d006 100644 --- a/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/Eigen/src/Core/arch/AVX/PacketMath.h @@ -72,6 +72,7 @@ template<> struct packet_traits : default_packet_traits HasLog1p = 1, HasExpm1 = 1, HasExp = 1, + HasNdtri = 1, HasSqrt = 1, HasRsqrt = 1, HasTanh = EIGEN_FAST_MATH, diff --git a/Eigen/src/Core/arch/AVX512/PacketMath.h b/Eigen/src/Core/arch/AVX512/PacketMath.h index e37855693..11c8dae02 100644 --- a/Eigen/src/Core/arch/AVX512/PacketMath.h +++ b/Eigen/src/Core/arch/AVX512/PacketMath.h @@ -97,6 +97,7 @@ template<> struct packet_traits : default_packet_traits HasLog = 1, HasLog1p = 1, HasExpm1 = 1, + HasNdtri = 1, #endif HasExp = 1, HasSqrt = EIGEN_FAST_MATH, diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 0fc673e12..13351d5ec 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -512,5 +512,60 @@ Packet pcos_float(const Packet& x) return psincos_float(x); } +/* polevl (modified for Eigen) + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * Scalar x, y, coef[N+1]; + * + * y = polevl( x, coef); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evl() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevl(). + * + * + * The Eigen implementation is templatized. For best speed, store + * coef as a const array (constexpr), e.g. + * + * const double coef[] = {1.0, 2.0, 3.0, ...}; + * + */ +template +struct ppolevl { + static EIGEN_STRONG_INLINE Packet run(const Packet& x, const typename unpacket_traits::type coeff[]) { + EIGEN_STATIC_ASSERT((N > 0), YOU_MADE_A_PROGRAMMING_MISTAKE); + return pmadd(ppolevl::run(x, coeff), x, pset1(coeff[N])); + } +}; + +template +struct ppolevl { + static EIGEN_STRONG_INLINE Packet run(const Packet& x, const typename unpacket_traits::type coeff[]) { + EIGEN_UNUSED_VARIABLE(x); + return pset1(coeff[0]); + } +}; + } // end namespace internal } // end namespace Eigen diff --git a/Eigen/src/Core/arch/GPU/PacketMath.h b/Eigen/src/Core/arch/GPU/PacketMath.h index d1df26e57..bdbaa5362 100644 --- a/Eigen/src/Core/arch/GPU/PacketMath.h +++ b/Eigen/src/Core/arch/GPU/PacketMath.h @@ -44,6 +44,7 @@ template<> struct packet_traits : default_packet_traits HasPolygamma = 1, HasErf = 1, HasErfc = 1, + HasNdtri = 1, HasI0e = 1, HasI1e = 1, HasIGamma = 1, @@ -78,6 +79,7 @@ template<> struct packet_traits : default_packet_traits HasPolygamma = 1, HasErf = 1, HasErfc = 1, + HasNdtri = 1, HasI0e = 1, HasI1e = 1, HasIGamma = 1, diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index b59e2c602..61500c06d 100755 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -112,6 +112,7 @@ template<> struct packet_traits : default_packet_traits HasLog = 1, HasLog1p = 1, HasExpm1 = 1, + HasNdtri = 1, HasExp = 1, HasSqrt = 1, HasRsqrt = 1, diff --git a/Eigen/src/Core/arch/SYCL/InteropHeaders.h b/Eigen/src/Core/arch/SYCL/InteropHeaders.h index ef66fc7de..d76030419 100644 --- a/Eigen/src/Core/arch/SYCL/InteropHeaders.h +++ b/Eigen/src/Core/arch/SYCL/InteropHeaders.h @@ -54,6 +54,7 @@ struct sycl_packet_traits : default_packet_traits { HasPolygamma = 0, HasErf = 0, HasErfc = 0, + HasNdtri = 0, HasIGamma = 0, HasIGammac = 0, HasBetaInc = 0, -- cgit v1.2.3