Hi, This is about a bug I found in PARI's Hermite Normal Form when testing my new Hermite Normal Form, and a fix from them.
William ---------- Forwarded message ---------- From: Karim Belabas <[EMAIL PROTECTED]> Date: Feb 18, 2008 2:49 AM Subject: Re: Bug#741: Fwd: bug in PARI's mathnf function To: William Stein <[EMAIL PROTECTED]>, [EMAIL PROTECTED] * William Stein [2008-02-16 23:47]: > Package: pari > Version: 2.3.3 [...] > PARI sometimes puts negative numbers in the *output* of mathnf(a, 1)[0], > which is a bug. Indeed. > * I didn't use mathnf(b) directly (the default option), since > already for a 20x18 matrix it > is too slow to be useful. As documented. [ Actually, I am going to change this: I don't see the point in defaulting to a slow routine; let mathnf choose depending on the matrix size. It should either call matdetint + mathnfmod, or mathnf(,1) ] > * I'm guessing maybe mathnf(b, 1) uses the modular hnf modulo the > determinant. Actually, no; mathnfmod does that. > If not, maybe you just need to add mutliples of rows until everything > is correctly normalized. We do that, with one optimization too many which sometimes cancelled the normalization step ( when the kernel is non trivial and we are "lucky": a coefficient which we want to set to 0 is already 0 ). It is fixed in both stable and unstable branches. I am attaching the (trivial) patch. Thanks for your report ! K.B. -- Karim Belabas Tel: (+33) (0)5 40 00 26 17 IMB, Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux.fr/~belabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
Index: src/basemath/alglin2.c =================================================================== --- src/basemath/alglin2.c (revision 9574) +++ src/basemath/alglin2.c (working copy) @@ -3082,11 +3082,9 @@ for (i=h[j]; i; i--) { a = gcoeff(A,i,j); - if (!signe(a)) continue; - k = c[i]; - ZV_elem(a,gcoeff(A,i,k), A,B, j,k); - ZM_reduce(A,B, i,k); + if (signe(a)) ZV_elem(a,gcoeff(A,i,k), A,B, j,k); + ZM_reduce(A,B, i,k); /* ensure non-negative entries, even if a = 0 */ if (low_stack(lim, stack_lim(av1,1))) { if (DEBUGMEM>1) pari_warn(warnmem,"hnfall[3], j = %ld", j);