aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src
diff options
context:
space:
mode:
authorGravatar Michael Figurnov <mfigurnov@google.com>2018-06-07 12:03:58 +0100
committerGravatar Michael Figurnov <mfigurnov@google.com>2018-06-07 12:03:58 +0100
commit5172a32849a310d8942273da307309721dc37c3f (patch)
treed4b482b1b1eec7e9425f141b3f62cf6894d4b4a6 /unsupported/Eigen/src
parent4bd158fa37b4bba74e6421575d5c69eeea547172 (diff)
Updated the stopping criteria in igammac_cf_impl.
Previously, when computing the derivative, it used a relative error threshold. Now it uses an absolute error threshold. The behavior for computing the value is unchanged. This makes more sense since we do not expect the derivative to often be close to zero. This change makes the derivatives about 30% faster across the board. The error for the igamma_der_a is almost unchanged, while for gamma_sample_der_alpha it is a bit worse for float32 and unchanged for float64.
Diffstat (limited to 'unsupported/Eigen/src')
-rw-r--r--unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h b/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h
index b24df2a95..78702905b 100644
--- a/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h
+++ b/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h
@@ -605,8 +605,7 @@ struct igammac_cf_impl {
break;
}
} else {
- if (numext::abs(dans_da - dans_da_prev) <=
- machep * numext::abs(dans_da)) {
+ if (numext::abs(dans_da - dans_da_prev) <= machep) {
break;
}
}
@@ -955,8 +954,8 @@ struct igamma_der_a_impl : igamma_generic_impl<Scalar, DERIVATIVE> {
* Accuracy estimation. For each a in [10^-2, 10^-1...10^3] we sample
* 50 Gamma random variables x ~ Gamma(x | a, 1), a total of 300 points.
* The ground truth is computed by mpmath. Mean absolute error:
- * float: 6.27648e-07
- * double: 4.60455e-12
+ * float: 6.17992e-07
+ * double: 4.60453e-12
*
* Reference:
* R. Moore. "Algorithm AS 187: Derivatives of the incomplete gamma
@@ -1000,8 +999,8 @@ struct gamma_sample_der_alpha_impl
* Accuracy estimation. For each alpha in [10^-2, 10^-1...10^3] we sample
* 50 Gamma random variables sample ~ Gamma(sample | alpha, 1), a total of 300
* points. The ground truth is computed by mpmath. Mean absolute error:
- * float: 1.0993e-06
- * double: 1.47631e-12
+ * float: 2.1686e-06
+ * double: 1.4774e-12
*
* Reference:
* M. Figurnov, S. Mohamed, A. Mnih "Implicit Reparameterization Gradients".