summaryrefslogtreecommitdiff
path: root/tests/tconst_catalan.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-06-07 14:27:34 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-06-07 14:27:34 +0000
commita75014cea797bd06d06b8d3ad71bffb6e571a16d (patch)
tree217d4aaac18aa3c11d22eb55c227783e3bdd9d60 /tests/tconst_catalan.c
parentd0c87f7fd9c49010010a4f24239eb1b32f0aff81 (diff)
downloadmpfr-a75014cea797bd06d06b8d3ad71bffb6e571a16d.tar.gz
Simplify test to use tgeneric.
Add note about Worst Case of const_catalan up to 100,000,000 git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3622 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tconst_catalan.c')
-rw-r--r--tests/tconst_catalan.c63
1 files changed, 16 insertions, 47 deletions
diff --git a/tests/tconst_catalan.c b/tests/tconst_catalan.c
index 23284363d..93575f2b8 100644
--- a/tests/tconst_catalan.c
+++ b/tests/tconst_catalan.c
@@ -19,24 +19,29 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include <stdio.h>
#include <stdlib.h>
#include "mpfr-test.h"
+/* Wrapper for tgeneric */
+static int
+my_const_catalan (mpfr_ptr x, mpfr_srcptr y, mp_rnd_t r)
+{
+ return mpfr_const_catalan (x, r);
+}
+
+#define RAND_FUNCTION(x) mpfr_set_ui(x,0,GMP_RNDN)
+#define TEST_FUNCTION my_const_catalan
+#include "tgeneric.c"
+
int
main (int argc, char *argv[])
{
- mpfr_t x, y, z, t;
- unsigned int err, prec, yprec, p0 = 2, p1 = 100;
- int rnd;
+ mpfr_t x;
tests_start_mpfr ();
- mpfr_init (x);
- mpfr_init (y);
- mpfr_init (z);
- mpfr_init (t);
-
- mpfr_set_prec (x, 32);
+ mpfr_init2 (x, 32);
(mpfr_const_catalan) (x, GMP_RNDN);
mpfr_mul_2exp (x, x, 32, GMP_RNDN);
if (mpfr_cmp_ui (x, 3934042271UL))
@@ -44,45 +49,9 @@ main (int argc, char *argv[])
printf ("Error in const_catalan for prec=32\n");
exit (1);
}
-
- for (prec = p0; prec <= p1; prec++)
- {
- mpfr_set_prec (z, prec);
- mpfr_set_prec (t, prec);
- yprec = prec + 10;
-
- for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
- {
- mpfr_set_prec (y, yprec);
- mpfr_const_catalan (y, (mp_rnd_t) rnd);
- err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
- if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
- {
- mpfr_set (t, y, (mp_rnd_t) rnd);
- mpfr_const_catalan (z, (mp_rnd_t) rnd);
- if (mpfr_cmp (t, z))
- {
- printf ("results differ for prec=%u rnd_mode=%s\n", prec,
- mpfr_print_rnd_mode ((mp_rnd_t) rnd));
- printf (" got ");
- mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
- puts ("");
- printf (" expected ");
- mpfr_out_str (stdout, 2, prec, t, GMP_RNDN);
- puts ("");
- printf (" approximation was ");
- mpfr_print_binary (y);
- puts ("");
- exit (1);
- }
- }
- }
- }
-
mpfr_clear (x);
- mpfr_clear (y);
- mpfr_clear (z);
- mpfr_clear (t);
+
+ test_generic (2, 200, 1);
tests_end_mpfr ();
return 0;