pub trait PolyRingStore: RingStore{
Show 17 methods
// Provided methods
fn indeterminate(&self) -> El<Self> { ... }
fn degree(&self, f: &El<Self>) -> Option<usize> { ... }
fn mul_assign_monomial(&self, lhs: &mut El<Self>, rhs_power: usize) { ... }
fn div_rem_monic(
&self,
lhs: El<Self>,
rhs: &El<Self>,
) -> (El<Self>, El<Self>) { ... }
fn truncate_monomials(&self, lhs: &mut El<Self>, truncated_at_degree: usize) { ... }
fn coefficient_at<'a>(
&'a self,
f: &'a El<Self>,
i: usize,
) -> &'a El<<Self::Type as RingExtension>::BaseRing> { ... }
fn terms<'a>(
&'a self,
f: &'a El<Self>,
) -> <Self::Type as PolyRing>::TermsIterator<'a> { ... }
fn from_terms<I>(&self, iter: I) -> El<Self>
where I: IntoIterator<Item = (El<<Self::Type as RingExtension>::BaseRing>, usize)> { ... }
fn try_from_terms<E, I>(&self, iter: I) -> Result<El<Self>, E>
where I: IntoIterator<Item = Result<(El<<Self::Type as RingExtension>::BaseRing>, usize), E>> { ... }
fn lc<'a>(
&'a self,
f: &'a El<Self>,
) -> Option<&'a El<<Self::Type as RingExtension>::BaseRing>> { ... }
fn normalize(&self, f: El<Self>) -> El<Self>
where <<Self::Type as RingExtension>::BaseRing as RingStore>::Type: DivisibilityRing + Domain { ... }
fn evaluate<R, H>(
&self,
f: &El<Self>,
value: &R::Element,
hom: H,
) -> R::Element
where R: ?Sized + RingBase,
H: Homomorphism<<<Self::Type as RingExtension>::BaseRing as RingStore>::Type, R> { ... }
fn into_lifted_hom<P, H>(
self,
from: P,
hom: H,
) -> CoefficientHom<P, Self, H>
where P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type> { ... }
fn lifted_hom<'a, P, H>(
&'a self,
from: P,
hom: H,
) -> CoefficientHom<P, &'a Self, H>
where P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type> { ... }
fn with_wrapped_indeterminate_dyn<'a, F, T>(&'a self, f: F) -> Vec<El<Self>> ⓘ
where F: FnOnce(&RingElementWrapper<&'a Self>) -> T,
T: IntoIterator<Item = RingElementWrapper<&'a Self>> { ... }
fn with_wrapped_indeterminate<'a, F, const M: usize>(
&'a self,
f: F,
) -> [El<Self>; M]
where F: FnOnce(&RingElementWrapper<&'a Self>) -> [RingElementWrapper<&'a Self>; M] { ... }
fn balance_poly(
&self,
f: &mut El<Self>,
) -> Option<El<<Self::Type as RingExtension>::BaseRing>>
where <<Self::Type as RingExtension>::BaseRing as RingStore>::Type: DivisibilityRing { ... }
}Provided Methods§
Sourcefn indeterminate(&self) -> El<Self>
fn indeterminate(&self) -> El<Self>
Sourcefn mul_assign_monomial(&self, lhs: &mut El<Self>, rhs_power: usize)
fn mul_assign_monomial(&self, lhs: &mut El<Self>, rhs_power: usize)
Sourcefn truncate_monomials(&self, lhs: &mut El<Self>, truncated_at_degree: usize)
fn truncate_monomials(&self, lhs: &mut El<Self>, truncated_at_degree: usize)
Sourcefn coefficient_at<'a>(
&'a self,
f: &'a El<Self>,
i: usize,
) -> &'a El<<Self::Type as RingExtension>::BaseRing>
fn coefficient_at<'a>( &'a self, f: &'a El<Self>, i: usize, ) -> &'a El<<Self::Type as RingExtension>::BaseRing>
Sourcefn terms<'a>(
&'a self,
f: &'a El<Self>,
) -> <Self::Type as PolyRing>::TermsIterator<'a>
fn terms<'a>( &'a self, f: &'a El<Self>, ) -> <Self::Type as PolyRing>::TermsIterator<'a>
See PolyRing::terms().
Sourcefn from_terms<I>(&self, iter: I) -> El<Self>
fn from_terms<I>(&self, iter: I) -> El<Self>
Computes the polynomial from the given terms.
If the iterator gives a term for the same monomial X^i multiple times,
the corresponding coefficients will be summed up.
Sourcefn try_from_terms<E, I>(&self, iter: I) -> Result<El<Self>, E>
fn try_from_terms<E, I>(&self, iter: I) -> Result<El<Self>, E>
Computes the polynomial from the given terms.
As opposed to PolyRingStore::from_terms(), the iterator may return errors,
in which case the computation is aborted and the first error is returned.
Sourcefn lc<'a>(
&'a self,
f: &'a El<Self>,
) -> Option<&'a El<<Self::Type as RingExtension>::BaseRing>>
fn lc<'a>( &'a self, f: &'a El<Self>, ) -> Option<&'a El<<Self::Type as RingExtension>::BaseRing>>
Returns a reference to the leading coefficient of the given polynomial, or None if the
polynomial is zero.
Sourcefn normalize(&self, f: El<Self>) -> El<Self>
fn normalize(&self, f: El<Self>) -> El<Self>
Divides each coefficient of this polynomial by its leading coefficient, thus making it monic.
Panics if the leading coefficient is not a unit.
§Example
let P = DensePolyRing::new(StaticRing::<i64>::RING, "X");
let f = P.from_terms([(6, 0), (3, 1)].into_iter());
assert_el_eq!(P, P.from_terms([(2, 0), (1, 1)].into_iter()), P.normalize(f));Sourcefn evaluate<R, H>(&self, f: &El<Self>, value: &R::Element, hom: H) -> R::Elementwhere
R: ?Sized + RingBase,
H: Homomorphism<<<Self::Type as RingExtension>::BaseRing as RingStore>::Type, R>,
fn evaluate<R, H>(&self, f: &El<Self>, value: &R::Element, hom: H) -> R::Elementwhere
R: ?Sized + RingBase,
H: Homomorphism<<<Self::Type as RingExtension>::BaseRing as RingStore>::Type, R>,
See PolyRing::evaluate().
Sourcefn into_lifted_hom<P, H>(self, from: P, hom: H) -> CoefficientHom<P, Self, H>where
P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
fn into_lifted_hom<P, H>(self, from: P, hom: H) -> CoefficientHom<P, Self, H>where
P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
Lifts the given homomorphism of base rings S -> R to the corresponding
homomorphism of polynomial rings S[X] -> R[X].
As opposed to PolyRingStore::lifted_hom(), this transfers the ownership
of self into the homomorphism object.
Sourcefn lifted_hom<'a, P, H>(
&'a self,
from: P,
hom: H,
) -> CoefficientHom<P, &'a Self, H>where
P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
fn lifted_hom<'a, P, H>(
&'a self,
from: P,
hom: H,
) -> CoefficientHom<P, &'a Self, H>where
P: RingStore,
P::Type: PolyRing,
H: Homomorphism<<<P::Type as RingExtension>::BaseRing as RingStore>::Type, <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
Lifts the given homomorphism of base rings S -> R to the corresponding
homomorphism of polynomial rings S[X] -> R[X].
Sourcefn with_wrapped_indeterminate_dyn<'a, F, T>(&'a self, f: F) -> Vec<El<Self>> ⓘwhere
F: FnOnce(&RingElementWrapper<&'a Self>) -> T,
T: IntoIterator<Item = RingElementWrapper<&'a Self>>,
fn with_wrapped_indeterminate_dyn<'a, F, T>(&'a self, f: F) -> Vec<El<Self>> ⓘwhere
F: FnOnce(&RingElementWrapper<&'a Self>) -> T,
T: IntoIterator<Item = RingElementWrapper<&'a Self>>,
Invokes the function with a wrapped version of the indeterminate of this poly ring. Use for convenient creation of polynomials.
Note however that PolyRingStore::from_terms() might be more performant.
If the number of polynomials to be created is known at compile time, it is more convenient
to instead use PolyRingStore::with_wrapped_indeterminate().
§Example
use feanor_math::assert_el_eq;
use feanor_math::ring::*;
use feanor_math::rings::poly::*;
use feanor_math::homomorphism::*;
use feanor_math::rings::zn::zn_64::*;
use feanor_math::rings::poly::dense_poly::*;
let base_ring = Zn::new(7);
let poly_ring = DensePolyRing::new(base_ring, "X");
let f_version1 = poly_ring.from_terms([(base_ring.int_hom().map(3), 0), (base_ring.int_hom().map(2), 1), (base_ring.one(), 3)].into_iter());
let f_version2 = poly_ring.with_wrapped_indeterminate_dyn(|x| [3 + 2 * x + x.pow_ref(3)]).into_iter().next().unwrap();
assert_el_eq!(poly_ring, f_version1, f_version2);Sourcefn with_wrapped_indeterminate<'a, F, const M: usize>(
&'a self,
f: F,
) -> [El<Self>; M]
fn with_wrapped_indeterminate<'a, F, const M: usize>( &'a self, f: F, ) -> [El<Self>; M]
Invokes the function with a wrapped version of the indeterminate of this poly ring. Use for convenient creation of polynomials.
Note however that PolyRingStore::from_terms() might be more performant.
If the number of polynomials to be created is not known at compile time, instead
use PolyRingStore::with_wrapped_indeterminate_dyn().
§Example
use feanor_math::assert_el_eq;
use feanor_math::ring::*;
use feanor_math::rings::poly::*;
use feanor_math::homomorphism::*;
use feanor_math::rings::zn::zn_64::*;
use feanor_math::rings::poly::dense_poly::*;
let base_ring = Zn::new(7);
let poly_ring = DensePolyRing::new(base_ring, "X");
let f_version1 = poly_ring.from_terms([(base_ring.int_hom().map(3), 0), (base_ring.int_hom().map(2), 1), (base_ring.one(), 3)].into_iter());
let [f_version2] = poly_ring.with_wrapped_indeterminate(|x| [3 + 2 * x + x.pow_ref(3)]);
assert_el_eq!(poly_ring, f_version1, f_version2);Sourcefn balance_poly(
&self,
f: &mut El<Self>,
) -> Option<El<<Self::Type as RingExtension>::BaseRing>>
fn balance_poly( &self, f: &mut El<Self>, ) -> Option<El<<Self::Type as RingExtension>::BaseRing>>
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.