This project implements several irreducibility and primitivity tests for polynomials in finite fields. Functions in this library are currently faster then similar function in Wolfram and Mathlab, but slower than functions from PARI/GP and FLINT. This library has a guarantee of NO UNDEFINED BEHAVIOUR by design.
Currently implemented tests:
- Berlekamp's irreducibility test
- Rabin's irreducibility test
- Ben-Or's irreducibility test
- Primitivity test
Recommended functions to use:
is_irreducible
for irreducibility testis_primitive
for primitivity test
- C++ 17 support
- Cmake 3.8 or higher
- Only PRIME fields are supported
- Multithreading is currently slow and not recommended for use
- Download the newest sources from
Releases
and unpack them to you root project folder (so that path to sources would be
./irrpoly
). Another way is using Git Submodules with commandgit submodule add https://github.com/irreducible-polynoms/irrpoly
- Check that your
CMAKE_CXX_STANDARD
is 17 or greater. - Add the following to your
CMakeLists.txt
:If you are not planning to use miltithread versions of algorithms be free to remove the last line. Now to link withadd_library(irrpoly INTERFACE) target_include_directories(irrpoly INTERFACE irrpoly/include) add_dependencies(irrpoly Threads::Threads)
irrpoly
library you need to addaftertarget_link_libraries("${PROJECT_NAME}" irrpoly)
add_executable
(replace${PROJECT_NAME}
with your target's name if it differs). - Add
#include <irrpoly.h>
to use the library. Remember that everything is dived intonamespace irrpoly
. - If you want to enable field consistency checks in Release configuration - place
#define IRRPOLY_RELEASE_CHECKED
before#include <irrpoly.h>
. By default this checks are enabled only for Debug configuration to speed up Release.
gf
– represents Galois field, to create new instance ofgf
usemake_gf
functiongfn
– represents a number in Galois fieldgfpoly
– represents a polynomial with coefficients from Galois fieldgfcheck
– contains checks implementations and some helpers (gcd
,derivative
)pipeline
– contains multithread pipeline for performing polynomial checks (examples of usage provided here), everything dived in namespaceirrpoly::multithread
nn
– redistributeddropbox::oxygen::nn
class (original source)
Auto-generated documentation is placed here and could be accessed as GitHub Pages.
- Building
tests
andexamples
executables if possible using Makefile commandmake build
of from any IDE supporting Cmake (JetBrains CLion, Visual Studio, etc.). Binaries are placed near sources in foldersbin/debug
andbin/release
. - Unit-tests and benchmarks are written using Catch2
- If PVS-Studio is installed - targets
*.analyze
are automatically added for all examples, use them for performing static analysis for possible vulnerabilities. When adding new examples preserve the following comment at the top of all*.cpp
files:// This is an open source non-commercial project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
- Updating documentation requires Doxygen and could be performed with
make docs
. - When bumping version number remember to change it both in CMakeLists.txt and in Doxyfile, and make a proper tag (or GitHub Release).
- If you are going to change check methods - verify their correctness using method described here.
The irrpoly
library is distributed under MIT license,
some parts of code are from boost
library originally distributed under Boost license
(redistributed under MIT license),
nn
class is originally distributed under Apache license (redistributed under MIT license).
Catch2
is not redistributed as it is only used for tests.
- Replace slow Berlekamp's matrix rank calculation algorithm in
is_irreducible_berlekamp
method with faster one. - Rewrite
pipeline
to make it faster (keep in mind that for most polynomials check functions will returnfalse
very quickly). C++ 20 coroutines could be used here. - Add support of COMPOSITE fields.
- Implement Distinct Degree Factorisation algorithm for irreducibility check.
- Research the possibility to use Discrete Fourier Transform to speed up polynomial multiplication and division methods.
- Check FLINT sources and find out the way Rabin's
irreducibility test is implemented there (there is some analogue of
x_pow_mod
function from this library), also inspect other methods as they are significantly faster then (nmod_poly_is_irreducible
stands for Berlekamp-Zassenhaus algorithm,nmod_poly_is_irreducible_ddf
stands for Distinct Degree Factorisation algorithm,nmod_poly_is_irreducible_rabin
stands for Rabin's irreducibility test)
- Wikipedia page on factorization of polynomials over finite fields.
- Davison, Joosten, Thiemann, Yamada. A Formalization of Berlekamp’s Factorization Algorithm.
- Panario, Pittel, Richmond, Viola. Analysis of Rabin's irreducibility test for polynomials over finite Fields.
- Gao, Panario. Tests and constructions of irreducible polynomials over finite fields.
- Hansen, Mullen. Primitive polynomials over finite fields.