Skip to main content

GroebnerBasis

Struct GroebnerBasis 

Source
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>

Source

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);
Source

pub fn minimize(self) -> Self

Minimize the basis: remove polynomials whose leading monomial is divisible by another element’s leading monomial.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<D: Clone + Domain, O: Clone + MonomialOrder> Clone for GroebnerBasis<D, O>

Source§

fn clone(&self) -> GroebnerBasis<D, O>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + Domain, O: Debug + MonomialOrder> Debug for GroebnerBasis<D, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>

Source§

fn eq(&self, other: &GroebnerBasis<D, O>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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>
where D: Send, O: Send, <D as Domain>::Element: Send,

§

impl<D, O> Sync for GroebnerBasis<D, O>
where D: Sync, O: Sync, <D as Domain>::Element: Sync,

§

impl<D, O> Unpin for GroebnerBasis<D, O>
where D: Unpin, O: Unpin, <D as Domain>::Element: Unpin,

§

impl<D, O> UnsafeUnpin for GroebnerBasis<D, O>

§

impl<D, O> UnwindSafe for GroebnerBasis<D, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.