You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/04/05 12:44:10 UTC
[commons-numbers] 05/06: Increase coverage in DigammaTest
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit 84f196290a6729f1570cea7ff7b198d94b19f257
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sun Apr 5 13:23:07 2020 +0100
Increase coverage in DigammaTest
---
.../org/apache/commons/numbers/gamma/DigammaTest.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
index 1d708bd..02d285f 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
@@ -42,8 +42,10 @@ public class DigammaTest {
@Test
public void testDigammaSmallArgs() {
- // values for negative powers of 10 from 1 to 30 as computed by webMathematica with 20 digits
- // see functions.wolfram.com
+ // values for negative powers of 10 from 1 to 30 as computed by webMathematica with 20 digits.
+ // For example, to compute trigamma($i) = Polygamma(1, $i), use
+ //
+ // http://functions.wolfram.com/webMathematica/Evaluated.jsp?name=PolyGamma2&plottype=0&vars={%221%22,%22$i%22}&digits=20
double[] expected = {-10.423754940411076795, -100.56088545786867450, -1000.5755719318103005,
-10000.577051183514335, -100000.57719921568107, -1.0000005772140199687e6, -1.0000000577215500408e7,
-1.0000000057721564845e8, -1.0000000005772156633e9, -1.0000000000577215665e10, -1.0000000000057721566e11,
@@ -56,6 +58,15 @@ public class DigammaTest {
}
@Test
+ public void testDigammaZero() {
+ // webMathematica states Complexinfinity.
+ // The value computed is Double.NEGATIVE_INFINITY but we leave this as a test for infinity
+ // since the next value down -Double.MIN_VALUE is Double.POSITIVE_INFINITY indicating
+ // a branch-but in the complex plane around 0.
+ Assertions.assertTrue(Double.isInfinite(Digamma.value(0.0)));
+ }
+
+ @Test
public void testDigammaNonRealArgs() {
Assertions.assertTrue(Double.isNaN(Digamma.value(Double.NaN)));
Assertions.assertTrue(Double.isInfinite(Digamma.value(Double.POSITIVE_INFINITY)));