[flint] 01/02: Imported Upstream version 2.4.5

Julien Puydt julien.puydt at laposte.net
Tue Feb 17 17:15:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository flint.

commit 01007afe2a7aa7b4f7d5557e888883c1d0441d56
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Tue Feb 17 17:00:47 2015 +0100

    Imported Upstream version 2.4.5
---
 .gitattributes                   |  3 --
 AUTHORS                          |  3 +-
 Makefile.in                      |  2 +-
 NEWS                             |  5 +++
 doc/latex/input/title.tex        |  4 +-
 flint.h                          |  4 +-
 fmpz_poly/gcd_heuristic.c        | 39 +++++++++++-------
 fmpz_poly/test/t-gcd_heuristic.c | 86 ++++++++++++++++++++++++++++++++++++++++
 8 files changed, 123 insertions(+), 23 deletions(-)

diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index c8d0373..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,3 +0,0 @@
-.gitattributes export-ignore
-.gitignote export-ignore
-
diff --git a/AUTHORS b/AUTHORS
index 6096835..3a97983 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -106,7 +106,8 @@ Bradshaw, Serge Torres, Dan Grayson, Martin Lee, Bob Smith, Antony Vennard,
 Fr\'{e}d\'{e}ric Chyzak, Julien Puydt, Dana Jacobsen, Michael Jacobson Jr.,
 Mike Stillman, Jan Englehardt, Jean-Pierre Flori, Jeroen Demeyer, Shi Bai,
 Qingwen Guan, Frithjof Schulze, Robert Baillie, Oleksandr Motsak, Hans
-Schoenemann, Janko Boehm, Ahmed Soliman, Francois Bissey and others.
+Schoenemann, Janko Boehm, Ahmed Soliman, Francois Bissey, Anton Mellit
+and others.
 
 $\bullet$ In addition Michael Abshoff, William Stein and Robert Bradshaw have
 contributed to the build system of FLINT.
diff --git a/Makefile.in b/Makefile.in
index 78e72a6..55062fa 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -75,7 +75,7 @@ distclean: clean
 	rm -f config.h fft_tuning.h fmpz-conversions.h Makefile fmpz/fmpz.c
 
 dist:
-	git archive --format tar --prefix flint-2.4.4/ flint-2.4 > ../flint-2.4.4.tar; gzip ../flint-2.4.4.tar
+	git archive --format tar --prefix flint-2.4.5/ flint-2.4 > ../flint-2.4.5.tar; gzip ../flint-2.4.5.tar
 
 profile: library $(PROF_SOURCES) $(EXT_PROF_SOURCES) build/profiler.o
 	mkdir -p build/profile
diff --git a/NEWS b/NEWS
index 0ae5a24..c8c2b9f 100644
--- a/NEWS
+++ b/NEWS
@@ -1100,3 +1100,8 @@ v 2.4.3 -- 01 Apr 2014
 
   * Fix a linker issue on Mac OSX.
 
+v 2.4.4 -- fixed a severe bug in flint's primality code (n_is_prime() affecting n_factor())
+
+v 2.4.5 -- fixed a severe bug in flint's fmpz_poly_gcd_heuristic, reported by
+    Anton Mellit.
+
diff --git a/doc/latex/input/title.tex b/doc/latex/input/title.tex
index afe73c6..ddd0ae0 100644
--- a/doc/latex/input/title.tex
+++ b/doc/latex/input/title.tex
@@ -11,8 +11,8 @@
 {\Large\itshape Fast Library for Number Theory}
 
 \vspace{0.5\textheight}
-{\large Version~2.4.4}\\[1.2\baselineskip]
-{\large 17 June 2014}\\[1.2\baselineskip]
+{\large Version~2.4.5}\\[1.2\baselineskip]
+{\large 17 Feb 2015}\\[1.2\baselineskip]
 {\large William Hart${}^*$, 
         Fredrik Johansson${}^\dag$, 
         Sebastian Pancratz${}^\ddag$}\\[1.2\baselineskip]
diff --git a/flint.h b/flint.h
index 707b71b..5b19d4e 100644
--- a/flint.h
+++ b/flint.h
@@ -61,8 +61,8 @@
 
 #define __FLINT_VERSION 2
 #define __FLINT_VERSION_MINOR 4
-#define __FLINT_VERSION_PATCHLEVEL 4 
-#define FLINT_VERSION "2.4.4"
+#define __FLINT_VERSION_PATCHLEVEL 5 
+#define FLINT_VERSION "2.4.5"
 #define __FLINT_RELEASE (__FLINT_VERSION * 10000 + \
                          __FLINT_VERSION_MINOR * 100 + \
                          __FLINT_VERSION_PATCHLEVEL)
diff --git a/fmpz_poly/gcd_heuristic.c b/fmpz_poly/gcd_heuristic.c
index 4a07dfb..9ed0098 100644
--- a/fmpz_poly/gcd_heuristic.c
+++ b/fmpz_poly/gcd_heuristic.c
@@ -85,7 +85,7 @@ int
 _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1, 
                                         const fmpz * poly2, slong len2)
 {
-	ulong bits1, bits2, max_bits, pack_bits, bound_bits, bits_G, bits_Q;
+   long bits1, bits2, max_bits, pack_bits, bound_bits, bits_G, bits_Q;
    ulong limbs1, limbs2, limbsg, pack_limbs, qlimbs;
    ulong log_glen, log_length;
    slong sign1, sign2, glen, qlen;
@@ -154,9 +154,17 @@ _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1,
       http://arxiv.org/abs/cs/0206032v1
    */
    bits1 = FLINT_ABS(_fmpz_vec_max_bits(A, len1));
-	bits2 = FLINT_ABS(_fmpz_vec_max_bits(B, len2));
-	max_bits = FLINT_MAX(bits1, bits2);
+   bits2 = FLINT_ABS(_fmpz_vec_max_bits(B, len2));
+   /* 
+      always extra bit for signs whether polys are signed or not, since we don't
+      know if any purported gcds/quotients will be signed
+   */
+   max_bits = FLINT_MAX(bits1, bits2) + 1; 
    			
+	/* 
+	   the +6 is chosen heuristically for performance; the theorem
+	   is satisfied with +3 (including a bit for signs)
+	*/
 	bound_bits = FLINT_MIN(bits1, bits2) + 6; 
 	pack_bits = FLINT_MAX(bound_bits, max_bits); /* need to pack original polys */
    pack_limbs = (pack_bits - 1)/FLINT_BITS + 1;
@@ -224,24 +232,26 @@ _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1,
       t = _fmpz_vec_init(len1 + glen);
       _fmpz_poly_bit_unpack(Q, qlen, q, pack_bits, 0);
       while (Q[qlen - 1] == 0) qlen--;
-      
+            
       /* divide by content */
       _fmpz_vec_scalar_divexact_fmpz(G, G, glen, gc);
 		
       /* check if we really need to multiply out to check for exact quotient */
       bits_G = FLINT_ABS(_fmpz_vec_max_bits(G, glen));
-		bits_Q = FLINT_ABS(_fmpz_vec_max_bits(Q, qlen));
-		log_glen = FLINT_BIT_COUNT(glen);
-		log_length = FLINT_MIN(log_glen, FLINT_BIT_COUNT(qlen));
+	  bits_Q = FLINT_ABS(_fmpz_vec_max_bits(Q, qlen));
+	  log_glen = FLINT_BIT_COUNT(glen);
+	  log_length = FLINT_MIN(log_glen, FLINT_BIT_COUNT(qlen));
        
-	   divides = (bits_G + bits_Q + log_length < pack_bits);
+	  /* allow one bit for signs */
+	  divides = (bits_G + bits_Q + log_length < pack_bits);
      
       if (!divides) /* need to multiply out to check exact quotient */
          divides = multiplies_out(A, len1, Q, qlen, G, glen, sign1, t);
 
 		if (divides) /* quotient really was exact */
 		{
-         flint_mpn_zero(q, qlimbs);
+           divides = 0;
+           flint_mpn_zero(q, qlimbs);
           
          if (flint_mpn_divides(q, array2, limbs2, arrayg, limbsg, temp)) 
 	      {
@@ -250,13 +260,14 @@ _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1,
             qlen = FLINT_MIN(len2, (qlimbs*FLINT_BITS - 1)/pack_bits + 1);
             _fmpz_poly_bit_unpack(Q, qlen, q, pack_bits, 0);
             while (Q[qlen - 1] == 0) qlen--;
-            
-            /* check if we really need to multiply out to check for exact quotient */
+			
+			/* check if we really need to multiply out to check for exact quotient */
             bits_Q = FLINT_ABS(_fmpz_vec_max_bits(Q, qlen));
-				log_length = FLINT_MIN(log_glen, FLINT_BIT_COUNT(qlen));
+		    log_length = FLINT_MIN(log_glen, FLINT_BIT_COUNT(qlen));
 
-				divides = (bits_G + bits_Q + log_length < pack_bits);
-		      
+			/* allow one bit for signs */
+			divides = (bits_G + bits_Q + log_length < pack_bits);
+       
             if (!divides) /* we need to multiply out */
                divides = multiplies_out(B, len2, Q, qlen, G, glen, sign1, t);
 			} 
diff --git a/fmpz_poly/test/t-gcd_heuristic.c b/fmpz_poly/test/t-gcd_heuristic.c
index d0d167c..a3df6ab 100644
--- a/fmpz_poly/test/t-gcd_heuristic.c
+++ b/fmpz_poly/test/t-gcd_heuristic.c
@@ -201,6 +201,60 @@ main(void)
         fmpz_poly_clear(r);
     }
 
+    /* 
+	   Check that gcd(f, ga) divides f and ga for small generic f, g
+	   and a small linear factor a. Exercises a bug found by Anton Mellit.
+	*/
+    for (i = 0; i < 1000 * flint_test_multiplier(); i++)
+    {
+        fmpz_poly_t a, d, f, g, q, r;
+        
+		fmpz_poly_init(d);
+        fmpz_poly_init(f);
+        fmpz_poly_init(g);
+        fmpz_poly_init(q);
+        fmpz_poly_init(r);
+        fmpz_poly_init(a);
+        fmpz_poly_randtest(f, state, n_randint(state, 10), 8);
+        fmpz_poly_randtest(g, state, n_randint(state, 10), 4);
+
+		/* multiply by small linear factor */
+		fmpz_poly_set_coeff_si(a, 0, n_randint(state, 2) ? 1 : -1);
+		fmpz_poly_set_coeff_si(a, 1, 1);
+		fmpz_poly_mul(g, g, a);
+		
+        d1 = fmpz_poly_gcd_heuristic(d, f, g);
+		
+        if (d1)
+        {
+           if (fmpz_poly_is_zero(d))
+		      result = fmpz_poly_is_zero(f) && fmpz_poly_is_zero(g);
+		   else
+		   {
+		      fmpz_poly_divrem_divconquer(q, r, f, d);
+              result = fmpz_poly_is_zero(r);
+              fmpz_poly_divrem_divconquer(q, r, g, d);
+              result &= fmpz_poly_is_zero(r);
+		   }
+		   
+           if (!result)
+           {
+              flint_printf("FAIL (gcd(f, g) | f and g):\n");
+              flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n");
+              flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n");
+              flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n");
+              abort();
+           }
+        }
+
+        fmpz_poly_clear(a);
+        fmpz_poly_clear(d);
+        fmpz_poly_clear(f);
+        fmpz_poly_clear(g);
+        fmpz_poly_clear(q);
+        fmpz_poly_clear(r);
+    }
+
     /* Sebastian's test case */
     {
        fmpz_poly_t a, b, d;
@@ -228,6 +282,38 @@ main(void)
        fmpz_poly_clear(d);
     }
 
+    /* Anton Mellit's test case */
+    {
+       fmpz_poly_t a, b, d;
+       int heuristic;
+	   
+       fmpz_poly_init(a);
+       fmpz_poly_init(b);
+       fmpz_poly_init(d);
+
+	   /* 
+	       b = 3*q^12 - 8*q^11 - 24*q^10 - 48*q^9 - 84*q^8 - 92*q^7 - 92*q^6 - 
+               70*q^5 - 50*q^4 - 27*q^3 - 13*q^2 - 4*q - 1
+		   a = q^13 - 2*q^12 + 2*q^10 - q^9
+	   */
+       fmpz_poly_set_str(b, "13  -1 -4 -13 -27 -50 -70 -92 -92 -84 -48 -24 -8 3");
+	   fmpz_poly_set_str(a, "14  0 0 0 0 0 0 0 0 0 -1 2 0 -2 1");
+	   
+       heuristic = fmpz_poly_gcd_heuristic(d, a, b);
+
+       result = (heuristic == 0 || (d->length == 1 && fmpz_is_one(d->coeffs)));
+       if (!result)
+       {
+          flint_printf("FAIL Mellit test case:\n");
+          fmpz_poly_print(d); flint_printf("\n"); 
+          abort();
+       }
+
+       fmpz_poly_clear(a);
+       fmpz_poly_clear(b);
+       fmpz_poly_clear(d);
+    }
+
     FLINT_TEST_CLEANUP(state);
     
     flint_printf("PASS\n");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/flint.git



More information about the debian-science-commits mailing list