pub trait MultivariatePolyRing: RingExtension {
type Monomial;
type TermIter<'a>: Iterator<Item = (&'a El<Self::BaseRing>, &'a Self::Monomial)>
where Self: 'a;
Show 21 methods
// Required methods
fn indeterminate_count(&self) -> usize;
fn create_monomial<I>(&self, exponents: I) -> Self::Monomial
where I: IntoIterator<Item = usize>,
I::IntoIter: ExactSizeIterator;
fn mul_assign_monomial(
&self,
f: &mut Self::Element,
monomial: Self::Monomial,
);
fn coefficient_at<'a>(
&'a self,
f: &'a Self::Element,
m: &Self::Monomial,
) -> &'a El<Self::BaseRing>;
fn exponent_at(&self, m: &Self::Monomial, var_index: usize) -> usize;
fn terms<'a>(&'a self, f: &'a Self::Element) -> Self::TermIter<'a>;
// Provided methods
fn indeterminate(&self, i: usize) -> Self::Monomial { ... }
fn expand_monomial_to(&self, m: &Self::Monomial, out: &mut [usize]) { ... }
fn create_term(
&self,
coeff: El<Self::BaseRing>,
monomial: Self::Monomial,
) -> Self::Element { ... }
fn LT<'a, O: MonomialOrder>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)> { ... }
fn largest_term_lt<'a, O: MonomialOrder>(
&'a self,
f: &'a Self::Element,
order: O,
lt_than: &Self::Monomial,
) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)> { ... }
fn add_assign_from_terms<I>(&self, lhs: &mut Self::Element, rhs: I)
where I: IntoIterator<Item = (El<Self::BaseRing>, Self::Monomial)> { ... }
fn map_terms<P, H>(
&self,
from: &P,
el: &P::Element,
hom: H,
) -> Self::Element
where P: ?Sized + MultivariatePolyRing,
H: Homomorphism<<P::BaseRing as RingStore>::Type, <Self::BaseRing as RingStore>::Type> { ... }
fn clone_monomial(&self, mon: &Self::Monomial) -> Self::Monomial { ... }
fn appearing_indeterminates(&self, f: &Self::Element) -> Vec<(usize, usize)> { ... }
fn monomial_mul(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Self::Monomial { ... }
fn monomial_deg(&self, mon: &Self::Monomial) -> usize { ... }
fn monomial_lcm(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Self::Monomial { ... }
fn monomial_div(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Result<Self::Monomial, Self::Monomial> { ... }
fn evaluate<R, V, H>(
&self,
f: &Self::Element,
value: V,
hom: H,
) -> R::Element
where R: ?Sized + RingBase,
H: Homomorphism<<Self::BaseRing as RingStore>::Type, R>,
V: VectorFn<R::Element> { ... }
fn specialize(
&self,
f: &Self::Element,
var: usize,
val: &Self::Element,
) -> Self::Element { ... }
}Expand description
Trait for multivariate polynomial rings.
Required Associated Types§
type Monomial
type TermIter<'a>: Iterator<Item = (&'a El<Self::BaseRing>, &'a Self::Monomial)> where Self: 'a
Required Methods§
Sourcefn indeterminate_count(&self) -> usize
fn indeterminate_count(&self) -> usize
Returns the number of variables of this polynomial ring, i.e. the transcendence degree of the base ring.
Sourcefn create_monomial<I>(&self, exponents: I) -> Self::Monomial
fn create_monomial<I>(&self, exponents: I) -> Self::Monomial
Creates a monomial with the given exponents.
Note that when building a polynomial, the most convenient method is usually
to use MultivariatePolyRingStore::with_wrapped_indeterminates().
§Example
let poly_ring = MultivariatePolyRingImpl::new(StaticRing::<i64>::RING, 3);
let x_as_monomial = poly_ring.create_monomial([1, 0, 0]);
let x_as_poly = poly_ring.create_term(1, x_as_monomial);
assert_eq!("X0", format!("{}", poly_ring.format(&x_as_poly)));Sourcefn mul_assign_monomial(&self, f: &mut Self::Element, monomial: Self::Monomial)
fn mul_assign_monomial(&self, f: &mut Self::Element, monomial: Self::Monomial)
Multiplies the given polynomial with the given monomial.
Sourcefn coefficient_at<'a>(
&'a self,
f: &'a Self::Element,
m: &Self::Monomial,
) -> &'a El<Self::BaseRing>
fn coefficient_at<'a>( &'a self, f: &'a Self::Element, m: &Self::Monomial, ) -> &'a El<Self::BaseRing>
Returns the coefficient corresponding to the given monomial in the given polynomial. If the polynomial does not contain a term with that monomial, zero is returned.
Sourcefn exponent_at(&self, m: &Self::Monomial, var_index: usize) -> usize
fn exponent_at(&self, m: &Self::Monomial, var_index: usize) -> usize
Returns the power of the var_index-th variable in the given monomial.
In other words, this maps X1^i1 ... Xm^im to i(var_index).
Provided Methods§
Sourcefn indeterminate(&self, i: usize) -> Self::Monomial
fn indeterminate(&self, i: usize) -> Self::Monomial
Returns the monomial Xi, where Xi is the i-th generator of this ring.
Sourcefn expand_monomial_to(&self, m: &Self::Monomial, out: &mut [usize])
fn expand_monomial_to(&self, m: &Self::Monomial, out: &mut [usize])
Writes the powers of each variable in the given monomial into the given output slice.
This is equivalent to performing out[i] = self.exponent_at(m, i) for
every i in 0..self.indeterminate_count().
Sourcefn create_term(
&self,
coeff: El<Self::BaseRing>,
monomial: Self::Monomial,
) -> Self::Element
fn create_term( &self, coeff: El<Self::BaseRing>, monomial: Self::Monomial, ) -> Self::Element
Creates a new single-term polynomial.
Sourcefn LT<'a, O: MonomialOrder>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)>
fn LT<'a, O: MonomialOrder>( &'a self, f: &'a Self::Element, order: O, ) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)>
Returns the Leading Term of f, i.e. the term whose monomial is largest w.r.t. the given order.
Sourcefn largest_term_lt<'a, O: MonomialOrder>(
&'a self,
f: &'a Self::Element,
order: O,
lt_than: &Self::Monomial,
) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)>
fn largest_term_lt<'a, O: MonomialOrder>( &'a self, f: &'a Self::Element, order: O, lt_than: &Self::Monomial, ) -> Option<(&'a El<Self::BaseRing>, &'a Self::Monomial)>
Returns the term of f whose monomial is largest (w.r.t. the given order) among all monomials smaller than lt_than.
fn add_assign_from_terms<I>(&self, lhs: &mut Self::Element, rhs: I)
Sourcefn map_terms<P, H>(&self, from: &P, el: &P::Element, hom: H) -> Self::Elementwhere
P: ?Sized + MultivariatePolyRing,
H: Homomorphism<<P::BaseRing as RingStore>::Type, <Self::BaseRing as RingStore>::Type>,
fn map_terms<P, H>(&self, from: &P, el: &P::Element, hom: H) -> Self::Elementwhere
P: ?Sized + MultivariatePolyRing,
H: Homomorphism<<P::BaseRing as RingStore>::Type, <Self::BaseRing as RingStore>::Type>,
Applies the given homomorphism R -> S to each coefficient of the given polynomial
in R[X1, ..., Xm] to produce a monomial in S[X1, ..., Xm].
fn clone_monomial(&self, mon: &Self::Monomial) -> Self::Monomial
Sourcefn appearing_indeterminates(&self, f: &Self::Element) -> Vec<(usize, usize)>
fn appearing_indeterminates(&self, f: &Self::Element) -> Vec<(usize, usize)>
Returns a list of all variables appearing in the given polynomial. Associated with each variable is the highest degree in which it appears in some term.
§Example
let poly_ring = MultivariatePolyRingImpl::new(StaticRing::<i64>::RING, 2);
let [f, g] = poly_ring.with_wrapped_indeterminates(|[X, Y]| [1 + X + X.pow_ref(2) * Y, X.pow_ref(3)]);
assert_eq!(vec![(0, 2), (1, 1)], poly_ring.appearing_indeterminates(&f));
assert_eq!(vec![(0, 3)], poly_ring.appearing_indeterminates(&g));Sourcefn monomial_mul(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Self::Monomial
fn monomial_mul( &self, lhs: Self::Monomial, rhs: &Self::Monomial, ) -> Self::Monomial
Multiplies two monomials.
Sourcefn monomial_deg(&self, mon: &Self::Monomial) -> usize
fn monomial_deg(&self, mon: &Self::Monomial) -> usize
Returns the degree of a monomial, i.e. the sum of the exponents of all variables.
Sourcefn monomial_lcm(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Self::Monomial
fn monomial_lcm( &self, lhs: Self::Monomial, rhs: &Self::Monomial, ) -> Self::Monomial
Returns the least common multiple of two monomials.
Sourcefn monomial_div(
&self,
lhs: Self::Monomial,
rhs: &Self::Monomial,
) -> Result<Self::Monomial, Self::Monomial>
fn monomial_div( &self, lhs: Self::Monomial, rhs: &Self::Monomial, ) -> Result<Self::Monomial, Self::Monomial>
Computes the quotient of two monomials.
If lhs does not divide rhs, this returns Result::Err with the monomial
lhs / gcd(rhs, lhs).
Sourcefn evaluate<R, V, H>(&self, f: &Self::Element, value: V, hom: H) -> R::Element
fn evaluate<R, V, H>(&self, f: &Self::Element, value: V, hom: H) -> R::Element
Evaluates the given polynomial at the given values.
§Example
let poly_ring = MultivariatePolyRingImpl::new(StaticRing::<i64>::RING, 2);
let [f] = poly_ring.with_wrapped_indeterminates(|[X, Y]| [1 + X + X.pow_ref(2) * Y]);
assert_eq!(1 + 5 + 5 * 5 * 8, poly_ring.evaluate(&f, [5, 8].clone_ring_els(StaticRing::<i64>::RING), &poly_ring.base_ring().identity()));Sourcefn specialize(
&self,
f: &Self::Element,
var: usize,
val: &Self::Element,
) -> Self::Element
fn specialize( &self, f: &Self::Element, var: usize, val: &Self::Element, ) -> Self::Element
Replaces the given indeterminate in the given polynomial by the value val.
Conceptually, this is similar to MultivariatePolyRing::evaluate(), but less general,
which can allow a faster implementation sometimes. In particular, this only replaces a single
indeterminate, and does not change the ring.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.