aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Till Hoffmann <tillahoffmann@gmail.com>2016-04-10 00:37:53 +0100
committerGravatar Till Hoffmann <tillahoffmann@gmail.com>2016-04-10 00:37:53 +0100
commit643b6976493c122ffb7205cc3ab893f28f9e1634 (patch)
treec2f363dba3d180cdff33088fdbc7e8255794a7b2 /Eigen
parent7f4826890cb5b7edddba57e38e67e9358b1a00c4 (diff)
Proper handling of domain errors.
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/SpecialFunctions.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/Eigen/src/Core/SpecialFunctions.h b/Eigen/src/Core/SpecialFunctions.h
index 954972cdd..2dc7b22fc 100644
--- a/Eigen/src/Core/SpecialFunctions.h
+++ b/Eigen/src/Core/SpecialFunctions.h
@@ -970,9 +970,14 @@ struct polygamma_impl {
static Scalar run(Scalar n, Scalar x) {
Scalar zero = 0.0, one = 1.0;
Scalar nplus = n + one;
+ const Scalar nan = NumTraits<Scalar>::quiet_NaN();
+ // Check that n is an integer
+ if (numext::floor(n) != n) {
+ return nan;
+ }
// Just return the digamma function for n = 1
- if (n == zero) {
+ else if (n == zero) {
return digamma_impl<Scalar>::run(x);
}
// Use the same implementation as scipy