summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-22 07:38:25 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-22 07:38:25 +0000
commit0fc077615aa0ee30041eed67dcde612cf5347d9b (patch)
treea82fa5f969dd46858b7e351df3d9dcfc1200bbb4 /tests
parentd1f81a6d27597826afdad3ec5d3e28d0884ecc03 (diff)
downloadmpfr-0fc077615aa0ee30041eed67dcde612cf5347d9b.tar.gz
[tests/tj1.c] added test for j1(z) with small z
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12038 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tj1.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/tj1.c b/tests/tj1.c
index 534b4486c..a9bc4b08a 100644
--- a/tests/tj1.c
+++ b/tests/tj1.c
@@ -27,6 +27,45 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#define REDUCE_EMAX 262143 /* otherwise arg. reduction is too expensive */
#include "tgeneric.c"
+/* test for small input, where j1(x) = x/2 - x^3/16 + ... */
+static void
+test_small (void)
+{
+ mpfr_t x, y;
+ int inex, sign;
+ mpfr_exp_t e, emin;
+
+ mpfr_init2 (x, 10);
+ mpfr_init2 (y, 10);
+ emin = mpfr_get_emin ();
+ for (e = -4; e >= -30; e--)
+ {
+ if (e == -30)
+ {
+ e = mpfr_get_emin_min () - 1;
+ mpfr_set_emin (e + 1);
+ }
+ for (sign = -1; sign <= 1; sign += 2)
+ {
+ mpfr_set_si_2exp (x, sign, e, MPFR_RNDN);
+ inex = mpfr_j1 (y, x, MPFR_RNDN);
+ if (e >= -29)
+ {
+ MPFR_ASSERTN(mpfr_cmp_si_2exp (y, sign, e - 1) == 0);
+ MPFR_ASSERTN(inex * sign > 0);
+ }
+ else
+ {
+ MPFR_ASSERTN(mpfr_zero_p (y));
+ MPFR_ASSERTN(mpfr_signbit(y) ^ (sign > 0));
+ }
+ }
+ }
+ mpfr_set_emin (emin);
+ mpfr_clear (x);
+ mpfr_clear (y);
+}
+
int
main (int argc, char *argv[])
{
@@ -34,6 +73,8 @@ main (int argc, char *argv[])
tests_start_mpfr ();
+ test_small ();
+
mpfr_init (x);
mpfr_init (y);