sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

[with patch and spkg] basic arithmetic using FLINT is broken (very serious!) #6919

Closed williamstein closed 15 years ago

williamstein commented 15 years ago

Mariah Lenox reported:

R.<x> = PolynomialRing(ZZ)
A = 2^(2^17+2^15)  # note the 2 rather than the "s"
a = A * x^31
b = (A * x) * x^30
a == b   # prints "False" ???

But

R.<x> = PolynomialRing(ZZ, implementation='NTL')
A = 2^(2^17+2^15)  # note the 2 rather than the "s"
a = A * (x^31)
b = A * x * (x^30)
a == b   

gives True. So this is definitely either a bug in FLINT (highly likely), or a bug in our wrapper (much less likely, since our wrapper is so generic:

cpdef RingElement _mul_(self, RingElement right):
    r"""
    Returns self multiplied by right.

    EXAMPLES::

        sage: R.<x> = PolynomialRing(ZZ)
        sage: (x - 2)*(x^2 - 8*x + 16)
        x^3 - 10*x^2 + 32*x - 32
    """
    cdef Polynomial_integer_dense_flint x = self._new()
    _sig_on
    fmpz_poly_mul(x.__poly, self.__poly,
            (<Polynomial_integer_dense_flint>right).__poly)
    _sig_off
    return x

}}}

CC: @wbhart @burcin

Component: basic arithmetic

Author: Mike Hansen, William Stein

Reviewer: John Palmieri, Minh Van Nguyen

Merged: Sage 4.1.2.alpha4

Issue created by migration from https://trac.sagemath.org/ticket/6919

burcin commented 15 years ago
comment:2
Bill Hart <goodwillhart@googlemail.com> wrote:
<snip>
> It was caused by a bug in the FLINT FFT (the first ever found). I
> tracked the bug down to a specific piece of code and David Harvey has
> supplied a fix. There will be a new version of FLINT to patch this
> bug.
mwhansen commented 15 years ago

Attachment: trac_6919.patch.gz

mwhansen commented 15 years ago

Author: Mike Hansen

mwhansen commented 15 years ago
comment:3

I've attached a patch which makes sure that this bug is indeed fixed by FLINT 1.5.0. The spkg can be found at http://sage.math.washington.edu/home/mhansen/flint-1.5.0.p0.spkg . This spkg is based of 1.3.0.p3 that Ondrej did.

williamstein commented 15 years ago
comment:4

I posted another spkg that adds one critical Cygwin fix, namely naming the library libflint.dll instead of libflint.so:

http://sage.math.washington.edu/home/wstein/patches/flint-1.5.0.p1.spkg

It's based exactly on mhansen's spkg.

jhpalmieri commented 15 years ago
comment:5

OS X 10.5, both 32-bit and 64-bit: first I applied the patch. This produced the doctest failure described in the ticket for the file libs/flint/flint.pyx. Then I did 'sage -f flint...' to install the new spkg . Then this file passed doctests.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago
comment:6

New FLINT package up at

http://sage.math.washington.edu/home/mvngu/release/spkg/standard/flint-1.5.0.p2.spkg

The only change from .p1 is:

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago
comment:7

See palmieri's and my reports at #6849.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Merged: Sage 4.1.2.alpha3

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Reviewer: John Palmieri, Minh Van Nguyen

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Changed author from Mike Hansen to Mike Hansen, William Stein

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago
comment:9

There is no 4.1.2.alpha3. Sage 4.1.2.alpha3 was William Stein's release for working on making the notebook a standalone package.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Changed merged from Sage 4.1.2.alpha3 to Sage 4.1.2.alpha4