Skip to content

implement fast ExpTrunc() and CharPolyMod()#23

Open
yyyyx4 wants to merge 3 commits intolibntl:mainfrom
yyyyx4:charpolymod
Open

implement fast ExpTrunc() and CharPolyMod()#23
yyyyx4 wants to merge 3 commits intolibntl:mainfrom
yyyyx4:charpolymod

Conversation

@yyyyx4
Copy link
Copy Markdown

@yyyyx4 yyyyx4 commented Sep 18, 2023

...for zz_pX and ZZ_pX. Both algorithms require divisions by scalars up to the precision, so they cannot be used when the degree is larger than the characteristic, but they give significant speedups in large characteristic.

Example benchmark results for CharPolyMod() in zz_pX, where red is the current version of NTL and blue is this branch:

Characteristic $11$ (essentially unchanged):
Benchmark results for characteristic 11

(The outliers appear when the new algorithm cannot be used and the minimal and characteristic polynomials are not the same; in such a case the library falls back to a much slower algorithm.)

Characteristic $99999989 ≈ 2^{26.6}$ (much faster):
Benchmark results for characteristic 99999989

I've confirmed on millions of random instances that the code works correctly, for prime characteristics and degrees up to 100.

@yyyyx4
Copy link
Copy Markdown
Author

yyyyx4 commented Mar 8, 2026

@victorshoup: Is there anything that needs to be done before this can get merged?

@victorshoup
Copy link
Copy Markdown
Contributor

@yyyyx4

Thanks for sending me the reminder and sorry for being so slow. Some questions...

  1. Are all new functions intended to be only for "internal consumption"? If not, should they be documented?
  2. Maybe your test and timing programs should go up to much larger degree?
  3. Should we add tests to the "make check" script? It would be nice if we git set coverage there...maybe we already do...I mean, maybe "make check" already touches your new code.

@yyyyx4
Copy link
Copy Markdown
Author

yyyyx4 commented Mar 14, 2026

Thanks for the quick response! I added some documentation for ExpTrunc(), and updated the documentation for CharPolyMod(), in the .txt files in doc/. I don't know how to update the HTML files (they seem to be autogenerated from the .txt?).

About your other questions:
(2) I did run some correctness and performance tests on much larger examples back in the day, albeit not as systematically as for the data shown in my initial comment above. Everything seemed fine.
(3) I don't mind adding my existing test programs somewhere, but I can't find very many tests at all in the existing codebase, and I'm not sure if it makes sense to start a comprehensive testing effort with this patch. Perhaps we can trust my offline testing that I did a while back for the moment, and eventually someone should go over the entire library and write tests for everything?

@victorshoup
Copy link
Copy Markdown
Contributor

victorshoup commented Mar 14, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants