aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/src/Core/arch/Default/Half.h3
-rw-r--r--test/half_float.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h
index 6529f14ec..56ff7cec3 100644
--- a/Eigen/src/Core/arch/Default/Half.h
+++ b/Eigen/src/Core/arch/Default/Half.h
@@ -729,6 +729,9 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half ceil(const half& a) {
return half(::ceilf(float(a)));
#endif
}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half fmod(const half& a, const half& b) {
+ return half(::fmodf(float(a), float(b)));
+}
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (min)(const half& a, const half& b) {
#if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530) || \
diff --git a/test/half_float.cpp b/test/half_float.cpp
index 1cfe69e93..729de1bc7 100644
--- a/test/half_float.cpp
+++ b/test/half_float.cpp
@@ -268,6 +268,11 @@ void test_basic_functions()
VERIFY_IS_EQUAL(float(log1p(half(0.0f))), 0.0f);
VERIFY_IS_APPROX(float(numext::log1p(half(10.0f))), 2.3978953f);
VERIFY_IS_APPROX(float(log1p(half(10.0f))), 2.3978953f);
+
+ VERIFY_IS_APPROX(numext::fmod(half(5.3f), half(2.0f)), half(1.3f));
+ VERIFY_IS_APPROX(fmod(half(5.3f), half(2.0f)), half(1.3f));
+ VERIFY_IS_APPROX(numext::fmod(half(-18.5f), half(-4.2f)), half(-1.7f));
+ VERIFY_IS_APPROX(fmod(half(-18.5f), half(-4.2f)), half(-1.7f));
}
void test_trigonometric_functions()