Trait feanor_math::rings::multivariate::MultivariatePolyRing
source · pub trait MultivariatePolyRing: RingExtension {
type MonomialVector: VectorViewMut<u16>;
type TermsIterator<'a>: Iterator<Item = (&'a El<Self::BaseRing>, &'a Monomial<Self::MonomialVector>)>
where Self: 'a;
Show 14 methods
// Required methods
fn indeterminate_len(&self) -> usize;
fn indeterminate(&self, i: usize) -> Self::Element;
fn terms<'a>(&'a self, f: &'a Self::Element) -> Self::TermsIterator<'a>;
fn mul_monomial(
&self,
el: &mut Self::Element,
m: &Monomial<Self::MonomialVector>,
);
fn coefficient_at<'a>(
&'a self,
f: &'a Self::Element,
m: &Monomial<Self::MonomialVector>,
) -> &'a El<Self::BaseRing>;
fn lm<'a, O>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<&'a Monomial<Self::MonomialVector>>
where O: MonomialOrder;
fn create_monomial<I: ExactSizeIterator<Item = u16>>(
&self,
exponents: I,
) -> Monomial<Self::MonomialVector>;
fn evaluate<R, V, H>(
&self,
f: &Self::Element,
values: V,
hom: &H,
) -> R::Element
where R: ?Sized + RingBase,
H: Homomorphism<<Self::BaseRing as RingStore>::Type, R>,
V: VectorView<R::Element>;
// Provided methods
fn monomial(&self, m: &Monomial<Self::MonomialVector>) -> Self::Element { ... }
fn add_assign_from_terms<I>(&self, lhs: &mut Self::Element, rhs: I)
where I: Iterator<Item = (El<Self::BaseRing>, Monomial<Self::MonomialVector>)> { ... }
fn lt<'a, O>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<(&'a El<Self::BaseRing>, &'a Monomial<Self::MonomialVector>)>
where O: MonomialOrder { ... }
fn specialize(
&self,
f: &Self::Element,
var: usize,
val: &Self::Element,
) -> Self::Element { ... }
fn appearing_variables(&self, f: &Self::Element) -> BTreeMap<usize, u16> { ... }
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> { ... }
}Expand description
Trait for rings that are multivariate polynomial rings in finitely many indeterminates
over a base ring, i.e. R[X0, X1, X2, ..., XN].
Currently, the only implementation of such rings is ordered::MultivariatePolyRingImpl,
which is stores all monomials in an ordered vector.
Required Associated Types§
type MonomialVector: VectorViewMut<u16>
type TermsIterator<'a>: Iterator<Item = (&'a El<Self::BaseRing>, &'a Monomial<Self::MonomialVector>)> where Self: 'a
Required Methods§
sourcefn indeterminate_len(&self) -> usize
fn indeterminate_len(&self) -> usize
Returns the number of indeterminates, i.e. the transcendence degree of this ring over its base ring.
sourcefn indeterminate(&self, i: usize) -> Self::Element
fn indeterminate(&self, i: usize) -> Self::Element
Returns the i-th indeterminate/variable/unknown as a ring element
sourcefn terms<'a>(&'a self, f: &'a Self::Element) -> Self::TermsIterator<'a>
fn terms<'a>(&'a self, f: &'a Self::Element) -> Self::TermsIterator<'a>
Returns all terms of the given polynomial. A term is a product
c * m with a nonzero coefficient c (i.e. element of the base ring)
and a monomial m.
sourcefn mul_monomial(
&self,
el: &mut Self::Element,
m: &Monomial<Self::MonomialVector>,
)
fn mul_monomial( &self, el: &mut Self::Element, m: &Monomial<Self::MonomialVector>, )
Multiplies the given polynomial with a monomial.
sourcefn coefficient_at<'a>(
&'a self,
f: &'a Self::Element,
m: &Monomial<Self::MonomialVector>,
) -> &'a El<Self::BaseRing>
fn coefficient_at<'a>( &'a self, f: &'a Self::Element, m: &Monomial<Self::MonomialVector>, ) -> &'a El<Self::BaseRing>
Returns the coefficient of the polynomial of the given monomial. If the monomial does not appear in the polynomial, this returns zero.
sourcefn lm<'a, O>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<&'a Monomial<Self::MonomialVector>>where
O: MonomialOrder,
fn lm<'a, O>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<&'a Monomial<Self::MonomialVector>>where
O: MonomialOrder,
Returns the leading monomial of the given polynomial.
The leading monomial is the monomial with nonzero coefficient that is largest w.r.t. the given monomial ordering.
fn create_monomial<I: ExactSizeIterator<Item = u16>>( &self, exponents: I, ) -> Monomial<Self::MonomialVector>
fn evaluate<R, V, H>(&self, f: &Self::Element, values: V, hom: &H) -> R::Elementwhere
R: ?Sized + RingBase,
H: Homomorphism<<Self::BaseRing as RingStore>::Type, R>,
V: VectorView<R::Element>,
Provided Methods§
sourcefn monomial(&self, m: &Monomial<Self::MonomialVector>) -> Self::Element
fn monomial(&self, m: &Monomial<Self::MonomialVector>) -> Self::Element
Returns the given monomial as a ring element
sourcefn add_assign_from_terms<I>(&self, lhs: &mut Self::Element, rhs: I)
fn add_assign_from_terms<I>(&self, lhs: &mut Self::Element, rhs: I)
Add-assigns to the given polynomial the polynomial implicitly given by the iterator over terms.
fn lt<'a, O>(
&'a self,
f: &'a Self::Element,
order: O,
) -> Option<(&'a El<Self::BaseRing>, &'a Monomial<Self::MonomialVector>)>where
O: MonomialOrder,
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.
The implementation is optimized using the facts that only one indeterminate is
replaced, and the new value is in the same ring (it can be a polynomial however).
sourcefn appearing_variables(&self, f: &Self::Element) -> BTreeMap<usize, u16>
fn appearing_variables(&self, f: &Self::Element) -> BTreeMap<usize, u16>
Returns all variables appearing in the given polynomial, together with their respective degrees.
§Example
let ring = ordered::MultivariatePolyRingImpl::<_, _, _, 3>::new(StaticRing::<i32>::RING, DegRevLex, default_memory_provider!());
let x = ring.indeterminate(0);
let y = ring.indeterminate(1);
let z = ring.indeterminate(2);
let poly = ring.add(x, ring.pow(z, 2));
assert_eq!([(0, 1), (2, 2)].into_iter().collect::<BTreeMap<_, _>>(), ring.appearing_variables(&poly));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>,
Computes the polynomial that results from applying hom to each coefficient of the input
polynomial. This is used to implement MultivariatePolyRingStore::lifted_hom().