sagemath / sage

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

Make FiniteField_pari_ffelt the default for generic finite fields #14888

Closed pjbruin closed 11 years ago

pjbruin commented 11 years ago

Ticket #12142 implements an interface to PARI's t_FFELT type for finite fields, which is much faster than the one currently used by Sage, in which finite field elements are PARI objects like Mod(Mod(1, 3)*a, Mod(1, 3)*a^17 + Mod(2, 3)*a + Mod(1, 3)). The attached patch makes the new implementation the default for those finite fields that currently use the slow PARI implementation, namely those of cardinality pn with p > 2 prime, n > 1 and pn > 216.

The actual switch is just a trivial change in the FiniteField constructor. The only other real addition is construction of Integer from t_FFELT; the rest of the patch fixes doctests. Almost all fixes are for doctests that assumed FiniteField_elt_pari to be the default. One somewhat notable point is that certain finite elements now compare differently (see the changed doctest in polynomial_zz_pex.py). This is because gcmp_sage (in sage/libs/pari/misc.h) compares all non-real PARI types via their string representations. With the new FiniteFieldElement_pari_ffelt, string comparison gives the same result as lexicographic comparison of polynomials expressing finite field elements in terms of the chosen generator, which is nice.

Apply:

Depends on #12142 Depends on #15124 Depends on #15125

Component: finite rings

Keywords: FiniteField performance

Author: Peter Bruin, Jeroen Demeyer

Reviewer: Jean-Pierre Flori, Jeroen Demeyer, Peter Bruin

Merged: sage-5.13.beta0

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

pjbruin commented 11 years ago

Changed reviewer from Jean-Pierre Flori, Jeroen Demeyer to Jean-Pierre Flori, Jeroen Demeyer, Peter Bruin

pjbruin commented 11 years ago
comment:43

OK, all tests pass.

jdemeyer commented 11 years ago

Merged: sage-5.13.beta0