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_irreduciblefor irreducibility testis_primitivefor 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_STANDARDis 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)irrpolylibrary 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_CHECKEDbefore#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 ofgfusemake_gffunctiongfn– 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::multithreadnn– redistributeddropbox::oxygen::nnclass (original source)
Auto-generated documentation is placed here and could be accessed as GitHub Pages.
- Building
testsandexamplesexecutables if possible using Makefile commandmake buildof from any IDE supporting Cmake (JetBrains CLion, Visual Studio, etc.). Binaries are placed near sources in foldersbin/debugandbin/release. - Unit-tests and benchmarks are written using Catch2
- If PVS-Studio is installed - targets
*.analyzeare 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*.cppfiles:// 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_berlekampmethod with faster one. - Rewrite
pipelineto make it faster (keep in mind that for most polynomials check functions will returnfalsevery 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_modfunction from this library), also inspect other methods as they are significantly faster then (nmod_poly_is_irreduciblestands for Berlekamp-Zassenhaus algorithm,nmod_poly_is_irreducible_ddfstands for Distinct Degree Factorisation algorithm,nmod_poly_is_irreducible_rabinstands 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.