This package is a SageMath interface to FGb and can be installed as a Python package for use with Sage. It provides a simple link between the C-interface of FGb and polynomials and ideals in Sage.
FGb is a C-library by J. C. Faugère for Gröbner basis computations, with support for:
- Gröbner bases over ℚ and finite prime fields
- parallel computations (over finite fields)
- elimination/block orders (degree-reverse-lexicographic, only)
See the examples and documentation at https://fgb-sage.readthedocs.io.
Requirements: Linux with a recent version of Sage (tested with Sage 9.5.rc0 on Ubuntu 20.04 as well as with Sage 9.6 from Arch Linux).
First, clone the repository from GitHub and then compile and run the tests:
git clone https://github.com/mwageringel/fgb_sage.git && cd fgb_sage sage setup.py test
After the tests passed successfully, run the following command to install the package for use with Sage:
sage -python -m pip install --upgrade --no-index -v .
Alternatively, to install into the Python user install directory (no root access required), run:
sage -python -m pip install --upgrade --no-index -v --user .
Installing into a virtual environment, assuming Sage is installed system-wide:
python -m venv --system-site-packages ./sage-venv # assumes that sage and python-setuptools are available system-wide source ./sage-venv/bin/activate # redefines `python` and `pip` using virtual environment python -m pip install --upgrade --no-index -v . cd sage-venv && python -m IPython # changing directory is important In [1]: from sage.all import * In [2]: R = PolynomialRing(QQ, 5, 'x', order="degrevlex(2),degrevlex(3)") In [3]: I = sage.rings.ideal.Cyclic(R) In [4]: import fgb_sage In [5]: gb = fgb_sage.groebner_basis(I)
If Sage was installed by the package manager of your Linux distribution, you may need to install a few more dependencies in order to compile this package. For example, on
Arch Linux:
pacman -S --asdeps cython python-pkgconfig
Ubuntu:
libgsl-dev liblinbox-dev libsingular4-dev libntl-dev libflint-dev libmpfr-dev libpari-dev python3-ipywidgets
Alternatively, you can download a Sage binary, use Sage via Docker or install Sage from source. See also issue #2.
- macOS: Support for macOS has been dropped for the time being due to difficulties in
compiling this package with
-fopenmp
since Sage version 8.8. Compiling the entirety of Sage with GCC support might make this work, but this was not tested. See issue #3. - Memory leaks: The underlying FGb program leaks memory, which can be a problem when computing many Gröbner bases in a single long-lived process. In this case, it might be better to split the computation into several processes or use a different Gröbner basis algorithm available in Sage.