Skip to main content

PolyRingStore

Trait PolyRingStore 

Source
pub trait PolyRingStore: RingStore
where Self::Type: PolyRing,
{
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 { ... }
}
Expand description

RingStore corresponding to PolyRing.

Provided Methods§

Source

fn indeterminate(&self) -> El<Self>

Source

fn degree(&self, f: &El<Self>) -> Option<usize>

Source

fn mul_assign_monomial(&self, lhs: &mut El<Self>, rhs_power: usize)

Source

fn div_rem_monic(&self, lhs: El<Self>, rhs: &El<Self>) -> (El<Self>, El<Self>)

Source

fn truncate_monomials(&self, lhs: &mut El<Self>, truncated_at_degree: usize)

Source

fn coefficient_at<'a>( &'a self, f: &'a El<Self>, i: usize, ) -> &'a El<<Self::Type as RingExtension>::BaseRing>

Source

fn terms<'a>( &'a self, f: &'a El<Self>, ) -> <Self::Type as PolyRing>::TermsIterator<'a>

Source

fn from_terms<I>(&self, iter: I) -> El<Self>
where I: IntoIterator<Item = (El<<Self::Type as RingExtension>::BaseRing>, usize)>,

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.

Source

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>>,

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.

Source

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.

Source

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));
Source

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>,

Source

fn into_lifted_hom<P, H>(self, from: P, hom: H) -> CoefficientHom<P, Self, H>

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.

Source

fn lifted_hom<'a, P, H>( &'a self, from: P, hom: H, ) -> CoefficientHom<P, &'a Self, H>

Lifts the given homomorphism of base rings S -> R to the corresponding homomorphism of polynomial rings S[X] -> R[X].

Source

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);
Source

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],

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);
Source

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.

Implementors§

Source§

impl<R: RingStore> PolyRingStore for R
where R::Type: PolyRing,