pub struct Monomial {
pub exponents: Vec<u32>,
}Fields§
§exponents: Vec<u32>Implementations§
Source§impl Monomial
impl Monomial
Sourcepub fn new(exponents: Vec<u32>) -> Self
pub fn new(exponents: Vec<u32>) -> Self
Examples found in repository?
examples/basic.rs (line 16)
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 one(nvars: usize) -> Self
pub fn nvars(&self) -> usize
pub fn degree(&self) -> u32
pub fn multiply(&self, other: &Self) -> Self
pub fn divides(&self, other: &Self) -> bool
pub fn divide(&self, other: &Self) -> Option<Self>
pub fn lcm(&self, other: &Self) -> Self
pub fn compare(&self, other: &Self, order: MonomialOrder) -> Ordering
Trait Implementations§
impl Eq for Monomial
impl StructuralPartialEq for Monomial
Auto Trait Implementations§
impl Freeze for Monomial
impl RefUnwindSafe for Monomial
impl Send for Monomial
impl Sync for Monomial
impl Unpin for Monomial
impl UnwindSafe for Monomial
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