pub struct Polynomial<F> {
pub terms: Vec<Term<F>>,
pub nvars: usize,
pub order: MonomialOrder,
}Fields§
§terms: Vec<Term<F>>§nvars: usize§order: MonomialOrderImplementations§
Source§impl<F: Field> Polynomial<F>
impl<F: Field> Polynomial<F>
Sourcepub fn new(terms: Vec<Term<F>>, nvars: usize, order: MonomialOrder) -> Self
pub fn new(terms: Vec<Term<F>>, nvars: usize, order: MonomialOrder) -> Self
Examples found in repository?
examples/basic.rs (lines 12-29)
5fn main() {
6 // Example: Compute a Groebner basis for the ideal (x^2 + y^2 - 1, x - y)
7 // Variables: x = 0, y = 1
8 let nvars = 2;
9 let order = MonomialOrder::Lex;
10
11 // x^2 + y^2 - 1
12 let f = Polynomial::new(
13 vec![
14 Term::new(
15 BigRational::new(1.into(), 1.into()),
16 Monomial::new(vec![2, 0]),
17 ), // x^2
18 Term::new(
19 BigRational::new(1.into(), 1.into()),
20 Monomial::new(vec![0, 2]),
21 ), // y^2
22 Term::new(
23 BigRational::new((-1).into(), 1.into()),
24 Monomial::new(vec![0, 0]),
25 ), // -1
26 ],
27 nvars,
28 order,
29 );
30
31 // x - y
32 let g = Polynomial::new(
33 vec![
34 Term::new(
35 BigRational::new(1.into(), 1.into()),
36 Monomial::new(vec![1, 0]),
37 ), // x
38 Term::new(
39 BigRational::new((-1).into(), 1.into()),
40 Monomial::new(vec![0, 1]),
41 ), // -y
42 ],
43 nvars,
44 order,
45 );
46
47 // Compute the Groebner basis
48 match groebner_basis(vec![f, g], order, true) {
49 Ok(basis) => {
50 println!("Groebner basis:");
51 for (i, poly) in basis.iter().enumerate() {
52 println!("g{}: {}", i + 1, poly);
53 }
54 }
55 Err(e) => {
56 println!("Error computing Groebner basis: {e}");
57 }
58 }
59}pub fn zero(nvars: usize, order: MonomialOrder) -> Self
pub fn constant(coeff: F, nvars: usize, order: MonomialOrder) -> Self
pub fn is_zero(&self) -> bool
pub fn leading_term(&self) -> Option<&Term<F>>
pub fn leading_monomial(&self) -> Option<&Monomial>
pub fn leading_coefficient(&self) -> Option<&F>
pub fn make_monic(&self) -> Self
pub fn add(&self, other: &Self) -> Self
pub fn subtract(&self, other: &Self) -> Self
pub fn multiply_scalar(&self, scalar: &F) -> Self
pub fn multiply_monomial(&self, monomial: &Monomial) -> Self
pub fn multiply(&self, other: &Self) -> Self
pub fn s_polynomial(&self, other: &Self) -> Result<Self, PolynomialError>
pub fn reduce(&self, basis: &[Self]) -> Result<Self, PolynomialError>
Trait Implementations§
Source§impl<F: Clone> Clone for Polynomial<F>
impl<F: Clone> Clone for Polynomial<F>
Source§fn clone(&self) -> Polynomial<F>
fn clone(&self) -> Polynomial<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for Polynomial<F>
impl<F: Debug> Debug for Polynomial<F>
Source§impl<F: Field> Display for Polynomial<F>
impl<F: Field> Display for Polynomial<F>
Source§impl<F: PartialEq> PartialEq for Polynomial<F>
impl<F: PartialEq> PartialEq for Polynomial<F>
impl<F> StructuralPartialEq for Polynomial<F>
Auto Trait Implementations§
impl<F> Freeze for Polynomial<F>
impl<F> RefUnwindSafe for Polynomial<F>where
F: RefUnwindSafe,
impl<F> Send for Polynomial<F>where
F: Send,
impl<F> Sync for Polynomial<F>where
F: Sync,
impl<F> Unpin for Polynomial<F>where
F: Unpin,
impl<F> UnwindSafe for Polynomial<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more