[Gmp-commit] /var/hg/gmp-proj/mini-gmp: ...

mercurial at gmplib.org mercurial at gmplib.org
Thu Jan 12 10:18:05 CET 2012


details:   /var/hg/gmp-proj/mini-gmp/rev/8e338a441f3b
changeset: 71:8e338a441f3b
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Jan 12 10:18:01 2012 +0100
description:
...

diffstat:

 tests/t-lcm.c |  52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diffs (56 lines):

diff -r 922ff255e570 -r 8e338a441f3b tests/t-lcm.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t-lcm.c	Thu Jan 12 10:18:01 2012 +0100
@@ -0,0 +1,52 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "mini-random.h"
+
+#define MAXBITS 400
+#define COUNT 10000
+
+static void
+dump (const char *label, const mpz_t x)
+{
+  char *buf = mpz_get_str (NULL, 16, x);
+  fprintf (stderr, "%s: %s\n", label, buf);
+  free (buf);
+}
+
+int
+main (int argc, char **argv)
+{
+  unsigned i;
+  mpz_t a, b, g, s;
+  
+  hex_random_init ();
+
+  mpz_init (a);
+  mpz_init (b);
+  mpz_init (g);
+  mpz_init (s);
+
+  for (i = 0; i < COUNT; i++)
+    {
+      mini_random_op (OP_LCM, MAXBITS, a, b, s);
+      mpz_lcm (g, a, b);
+      if (mpz_cmp (g, s))
+	{
+	  fprintf (stderr, "mpz_lcm failed:\n");
+	  dump ("a", a);
+	  dump ("b", b);
+	  dump ("r", g);
+	  dump ("ref", s);
+	  abort ();
+	}
+    }
+
+  mpz_clear (a);
+  mpz_clear (b);
+  mpz_clear (g);
+  mpz_clear (s);
+
+  return 0;
+}


More information about the gmp-commit mailing list