Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap NTL's lzz_pE and lzz_pEX and use them #8109

Open
sagetrac-ylchapuy mannequin opened this issue Jan 28, 2010 · 15 comments
Open

wrap NTL's lzz_pE and lzz_pEX and use them #8109

sagetrac-ylchapuy mannequin opened this issue Jan 28, 2010 · 15 comments

Comments

@sagetrac-ylchapuy
Copy link
Mannequin

sagetrac-ylchapuy mannequin commented Jan 28, 2010

This should fasten polynomial arithmetic over finite fields of small characteristic.

Component: algebra

Keywords: ntl

Author: Yann Laigle-Chapuy

Reviewer: roed

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

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Jan 29, 2010

Attachment: trac_8109-lzz_pEX.patch.gz

needs #7841 (I guess)

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Jan 29, 2010

comment:1

Preliminary version.

note: this is mostly a copy of existing files for wrapping ZZ_pE and ZZ_pEX with
'sed s/ZZ/zz/g' applied.

warning: there is no test (yet) for checking that the modulus is < NTL_SP_BOUND

still, doctests pass and here are some results:

sage: c=ntl.zz_pEContext(ntl.zz_pX([1,1,1,1,1], 19800713)) 
sage: a = ntl.zz_pE([3,2], c); b = ntl.zz_pE([1,2], c)
sage: f = ntl.zz_pEX([a, b, b])
sage: p = f**123
sage: q = p+f**77+f
sage: 
sage: C=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1,1,1], 19800713)) 
sage: A = ntl.ZZ_pE([3,2], C); B = ntl.ZZ_pE([1,2], C)
sage: F = ntl.ZZ_pEX([A, B, B])
sage: P = F**123
sage: Q = P+F**77+F
sage: 
sage: %timeit p+q
625 loops, best of 3: 59.6 µs per loop
sage: %timeit P+Q
625 loops, best of 3: 180 µs per loop
sage: 
sage: %timeit p*q
125 loops, best of 3: 2.62 ms per loop
sage: %timeit P*Q
125 loops, best of 3: 5.65 ms per loop
sage: 
sage: %timeit p.gcd(q)
125 loops, best of 3: 7.28 ms per loop
sage: %timeit P.gcd(Q)
5 loops, best of 3: 62.5 ms per loop
sage: 
sage: %timeit p**17
5 loops, best of 3: 58 ms per loop
sage: %timeit P**17
5 loops, best of 3: 129 ms per loop

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Jan 29, 2010

Changed keywords from none to ntl

@sagetrac-ylchapuy sagetrac-ylchapuy mannequin added this to the sage-4.3.2 milestone Jan 29, 2010
@sagetrac-ylchapuy sagetrac-ylchapuy mannequin removed the wishlist item label Jan 29, 2010
@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Jan 29, 2010

comment:2

Replying to @sagetrac-ylchapuy:

warning: there is no test (yet) for checking that the modulus is < NTL_SP_BOUND

I must be tired... there is a check, it's done in the lzz_p class.

I guess this one is ready for review then. I will open another ticket to do the same as #7841 latter.

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Feb 1, 2010

use both patches

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Feb 1, 2010

comment:3

Attachment: trac_8109-lzz_pEX-part2.patch.gz

Finally, this is such a small patch that I add it here.
With both patches applied, the default implementation for polynomial ring is now based on NTL, and uses type ZZ or lzz depending on the characteristic (tested against NTL_SP_BOUND).

@roed314
Copy link
Contributor

roed314 commented Feb 8, 2010

Reviewer: roed

@roed314
Copy link
Contributor

roed314 commented Feb 8, 2010

comment:4

I'll review this. I'm working on multiple related things actually: improving finite fields (which I'm thinking of doing with a new templating class) and p-adic polynomials.

@roed314
Copy link
Contributor

roed314 commented Feb 9, 2010

comment:6

I see that you changed it to "needs work." One thing I noticed looking at the patch was that sage/libs/ntl/ntl_lzz_decl.pxd seems generally broken: shouldn't those be zz_p and lzz_p, not zz and lzz?

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Feb 10, 2010

Attachment: trac_8109-lzz_pEX-part3.patch.gz

replacing all previous ones

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Feb 10, 2010

comment:7

Attachment: trac_8109-lzz_pEX-all_in_one.patch.gz

Replying to @roed314:

I see that you changed it to "needs work." One thing I noticed looking at the patch was that sage/libs/ntl/ntl_lzz_decl.pxd seems generally broken: shouldn't those be zz_p and lzz_p, not zz and lzz?

It's even worse than that, this file just shouldn't exist :)
The last patch replaces all previous ones and should be almost ready for review. I will just check and address the comments made on #7841 before.

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Mar 10, 2010

Author: Yann Laigle-Chapuy

@sagetrac-ylchapuy
Copy link
Mannequin Author

sagetrac-ylchapuy mannequin commented Mar 10, 2010

comment:8

Attachment: trac_8109-lzz_pEX-copyrights.patch.gz

Apply only:

  • trac_8109-lzz_pEX-all_in_one.patch
  • trac_8109-lzz_pEX-copyrights.patch

in this order.

@malb
Copy link
Member

malb commented Apr 14, 2010

comment:9

I get doctest failures on sage.math:

sage -t  devel/sage/sage/graphs/graph_list.py # 0 doctests failed
sage -t  devel/sage/sage/schemes/elliptic_curves/ell_curve_isogeny.py # Killed/crashed
sage -t  devel/sage/sage/libs/ntl/ntl_lzz_pX.pyx # 5 doctests failed
sage -t  devel/sage/sage/libs/ntl/ntl_lzz_pEX_linkage.pxi # 3 doctests failed

Looks like a 64-bit thing?

sage -t  devel/sage/sage/libs/ntl/ntl_lzz_pEX_linkage.pxi
**********************************************************************
File "/mnt/usb1/scratch/malb/sage-4.3.3/devel/sage-main/sage/libs/ntl/ntl_lzz_pEX_linkage.pxi", line 178:
    sage: (1+a+a^2)*x - (1+x+x^2)
Expected:
    1152921504606847008*x^2 + (a^2 + a)*x + 1152921504606847008
Got:
    1030*x^2 + (a^2 + a)*x + 1030
**********************************************************************
File "/mnt/usb1/scratch/malb/sage-4.3.3/devel/sage-main/sage/libs/ntl/ntl_lzz_pEX_linkage.pxi", line 189:
    sage: -x
Expected:
    1152921504606847008*x
Got:
    1030*x
**********************************************************************
File "/mnt/usb1/scratch/malb/sage-4.3.3/devel/sage-main/sage/libs/ntl/ntl_lzz_pEX_linkage.pxi", line 308:
    sage: (a+1+x).xgcd(a+x)
Expected:
    (1, 1, 1152921504606847008)
Got:
    (1, 1, 1030)
**********************************************************************

@sagetrac-johanbosman
Copy link
Mannequin

sagetrac-johanbosman mannequin commented Aug 19, 2011

comment:10

The patch needs to be rebased as well.

@jdemeyer jdemeyer removed this from the sage-5.11 milestone Aug 13, 2013
@jdemeyer jdemeyer added this to the sage-5.12 milestone Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants