pub struct GroebnerBasis<D: Domain, O: MonomialOrder> {
pub basis: Vec<SparseMultivariatePolynomial<D, O>>,
}Expand description
A Gröbner basis for a polynomial ideal.
Fields§
§basis: Vec<SparseMultivariatePolynomial<D, O>>The polynomials forming the basis.
Implementations§
Source§impl<D: Domain, O: MonomialOrder> GroebnerBasis<D, O>
impl<D: Domain, O: MonomialOrder> GroebnerBasis<D, O>
Sourcepub fn buchberger(ideal: &[SparseMultivariatePolynomial<D, O>]) -> Self
pub fn buchberger(ideal: &[SparseMultivariatePolynomial<D, O>]) -> Self
Compute a Gröbner basis from a set of generators using Buchberger’s algorithm.
Requires that the coefficient domain supports exact division (i.e., is effectively a field). The algorithm will panic if division fails.
§Example
use ocas_domain::{RationalDomain, Rational};
use ocas_poly::sparse::Lex;
use ocas_poly::GroebnerBasis;
use ocas_poly::SparseMultivariatePolynomial;
let d = RationalDomain;
// ideal: x + y, x - y
let f1 = SparseMultivariatePolynomial::<_, Lex>::from_terms(d, 2, vec![
(vec![1, 0], Rational::new(1, 1)),
(vec![0, 1], Rational::new(1, 1)),
]);
let f2 = SparseMultivariatePolynomial::<_, Lex>::from_terms(d, 2, vec![
(vec![1, 0], Rational::new(1, 1)),
(vec![0, 1], Rational::new(-1, 1)),
]);
let gb = GroebnerBasis::buchberger(&[f1, f2]);
assert!(gb.basis.len() >= 2);Sourcepub fn minimize(self) -> Self
pub fn minimize(self) -> Self
Minimize the basis: remove polynomials whose leading monomial is divisible by another element’s leading monomial.
Sourcepub fn auto_reduce(self) -> Self
pub fn auto_reduce(self) -> Self
Inter-reduce the basis: reduce each element by the others and make each polynomial monic.
The algorithm processes elements in ascending order of leading monomial. Each element is reduced by all elements with strictly smaller leading monomials (those already in the result set). This ensures the standard reduced Gröbner basis property: no monomial of any basis element is divisible by the leading monomial of any other basis element.
Sourcepub fn is_groebner_basis(&self) -> bool
pub fn is_groebner_basis(&self) -> bool
Verify that this is indeed a Gröbner basis by checking that all S-polynomials reduce to zero.
Sourcepub fn reorder<O2: MonomialOrder>(&self) -> GroebnerBasis<D, O2>where
D: 'static,
pub fn reorder<O2: MonomialOrder>(&self) -> GroebnerBasis<D, O2>where
D: 'static,
Change the monomial order of this Gröbner basis.
The polynomials are re-interpreted under the target order O2
and the F4 algorithm is re-run. This is the simple reorder path
(Symbolica’s reorder::<Order>()). For zero-dimensional ideals,
use crate::groebner::fglm::fglm for a much faster conversion.
§Example
use ocas_domain::{RationalDomain, Rational};
use ocas_poly::sparse::{Grevlex, Lex};
use ocas_poly::{GroebnerBasis, SparseMultivariatePolynomial, f4};
let d = RationalDomain;
// ideal: x + y, x - y → basis {y, x} under Lex
let f1 = SparseMultivariatePolynomial::<_, Lex>::from_terms(d, 2, vec![
(vec![1, 0], Rational::new(1, 1)),
(vec![0, 1], Rational::new(1, 1)),
]);
let f2 = SparseMultivariatePolynomial::<_, Lex>::from_terms(d, 2, vec![
(vec![1, 0], Rational::new(1, 1)),
(vec![0, 1], Rational::new(-1, 1)),
]);
let gb_lex = f4::f4(&[f1, f2]);
let gb_grevlex = gb_lex.reorder::<Grevlex>();
assert!(gb_grevlex.is_groebner_basis());Trait Implementations§
Source§impl<D: Clone + Domain, O: Clone + MonomialOrder> Clone for GroebnerBasis<D, O>
impl<D: Clone + Domain, O: Clone + MonomialOrder> Clone for GroebnerBasis<D, O>
Source§fn clone(&self) -> GroebnerBasis<D, O>
fn clone(&self) -> GroebnerBasis<D, O>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<D: Debug + Domain, O: Debug + MonomialOrder> Debug for GroebnerBasis<D, O>
impl<D: Debug + Domain, O: Debug + MonomialOrder> Debug for GroebnerBasis<D, O>
impl<D: Eq + Domain, O: Eq + MonomialOrder> Eq for GroebnerBasis<D, O>
Source§impl<D: PartialEq + Domain, O: PartialEq + MonomialOrder> PartialEq for GroebnerBasis<D, O>
impl<D: PartialEq + Domain, O: PartialEq + MonomialOrder> PartialEq for GroebnerBasis<D, O>
impl<D: PartialEq + Domain, O: PartialEq + MonomialOrder> StructuralPartialEq for GroebnerBasis<D, O>
Auto Trait Implementations§
impl<D, O> Freeze for GroebnerBasis<D, O>
impl<D, O> RefUnwindSafe for GroebnerBasis<D, O>
impl<D, O> Send for GroebnerBasis<D, O>
impl<D, O> Sync for GroebnerBasis<D, O>
impl<D, O> Unpin for GroebnerBasis<D, O>
impl<D, O> UnsafeUnpin for GroebnerBasis<D, O>
impl<D, O> UnwindSafe for GroebnerBasis<D, O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more