diff options
author | 2016-04-10 00:37:53 +0100 | |
---|---|---|
committer | 2016-04-10 00:37:53 +0100 | |
commit | 643b6976493c122ffb7205cc3ab893f28f9e1634 (patch) | |
tree | c2f363dba3d180cdff33088fdbc7e8255794a7b2 /Eigen | |
parent | 7f4826890cb5b7edddba57e38e67e9358b1a00c4 (diff) |
Proper handling of domain errors.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/SpecialFunctions.h | 7 |
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 |