Struct feanor_math::wrapper::RingElementWrapper

source ·
pub struct RingElementWrapper<R>
where R: RingStore,
{ /* private fields */ }
Expand description

Stores a ring element together with its ring, so that ring operations do not require explicit mention of the ring object. This can be used both for convenience of notation (i.e. use a + b instead of ring.add(a, b)) and might also be necessary when e.g. storing elements in a set.

§Examples

 
let ring = DensePolyRing::new(StaticRing::<i64>::RING, "X");
let x = RingElementWrapper::new(&ring, ring.indeterminate());
println!("The result is: {}", x.clone() + x.clone() * x);
// instead of
let x = ring.indeterminate();
println!("The result is: {}", ring.format(&ring.add(ring.mul(ring.clone_el(&x), ring.clone_el(&x)), ring.clone_el(&x))));

Implementations§

source§

impl<R: RingStore> RingElementWrapper<R>

source

pub const fn new(ring: R, element: El<R>) -> Self

source

pub fn pow(self, power: usize) -> Self

source

pub fn unwrap(self) -> El<R>

Trait Implementations§

source§

impl<R: RingStore> Add for RingElementWrapper<R>

§

type Output = RingElementWrapper<R>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, R: RingStore> AddAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>

source§

fn add_assign(&mut self, rhs: &'a Self)

Performs the += operation. Read more
source§

impl<R: RingStore> AddAssign for RingElementWrapper<R>

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<R: RingStore + Clone> Clone for RingElementWrapper<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: RingStore> Debug for RingElementWrapper<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: RingStore> Deref for RingElementWrapper<R>

§

type Target = <<R as RingStore>::Type as RingBase>::Element

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<R: RingStore> Display for RingElementWrapper<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: RingStore + HashableElRingStore> Hash for RingElementWrapper<R>
where R::Type: HashableElRing,

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<R: RingStore> Mul for RingElementWrapper<R>

§

type Output = RingElementWrapper<R>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, R: RingStore> MulAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>

source§

fn mul_assign(&mut self, rhs: &'a Self)

Performs the *= operation. Read more
source§

impl<R: RingStore> MulAssign for RingElementWrapper<R>

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<R: RingStore> PartialEq for RingElementWrapper<R>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R: RingStore> Sub for RingElementWrapper<R>

§

type Output = RingElementWrapper<R>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, R: RingStore> SubAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>

source§

fn sub_assign(&mut self, rhs: &'a Self)

Performs the -= operation. Read more
source§

impl<R: RingStore> SubAssign for RingElementWrapper<R>

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<R: RingStore + Copy> Copy for RingElementWrapper<R>
where El<R>: Copy,

source§

impl<R: RingStore> Eq for RingElementWrapper<R>

Auto Trait Implementations§

§

impl<R> Freeze for RingElementWrapper<R>
where R: Freeze, <<R as RingStore>::Type as RingBase>::Element: Freeze,

§

impl<R> RefUnwindSafe for RingElementWrapper<R>

§

impl<R> Send for RingElementWrapper<R>
where R: Send, <<R as RingStore>::Type as RingBase>::Element: Send,

§

impl<R> Sync for RingElementWrapper<R>
where R: Sync, <<R as RingStore>::Type as RingBase>::Element: Sync,

§

impl<R> Unpin for RingElementWrapper<R>
where R: Unpin, <<R as RingStore>::Type as RingBase>::Element: Unpin,

§

impl<R> UnwindSafe for RingElementWrapper<R>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<R> DivisibilityRingStore for R

source§

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

source§

fn is_unit(&self, x: &El<Self>) -> bool

source§

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

source§

fn invert(&self, el: &El<Self>) -> Option<El<Self>>

source§

impl<R> ExtensionFieldStore for R

source§

impl<T> FFTTable for T
where T: Deref, <T as Deref>::Target: FFTTable,

§

type Ring = <<T as Deref>::Target as FFTTable>::Ring

source§

fn len(&self) -> usize

This FFTTable can compute the FFT of arrays of this length.
source§

fn ring(&self) -> &<T as FFTTable>::Ring

The underlying ring whose roots of unity are used by the FFT.
source§

fn root_of_unity( &self ) -> &<<<T as FFTTable>::Ring as RingStore>::Type as RingBase>::Element

The root of unity used for the FFT. While all primitive n-th roots of unity can be used equally for computing a Fourier transform, the concrete one used determines the order of the output values. Read more
source§

fn unordered_fft_permutation(&self, i: usize) -> usize

On input i, returns j such that unordered_fft(values)[i] contains the evaluation at zeta^j of values. Here zeta is the value returned by FFTTable::root_of_unity()
source§

fn unordered_fft_permutation_inv(&self, i: usize) -> usize

The inverse of FFTTable::unordered_fft_permutation(), i.e. for all i, have self.unordered_fft_permutation_inv(self.unordered_fft_permutation(i)) == i.
source§

fn fft<V, S, M, H>(&self, values: V, memory_provider: &M, hom: &H)

Computes inplace the Fourier transform of the given values over the given ring. The output is in standard order, i.e. the i-th output element is the evaluation of the input at self.root_of_unity()^-i (note the -, which is standard convention for Fourier transforms). Read more
source§

fn inv_fft<V, S, M, H>(&self, values: V, memory_provider: &M, hom: &H)

Computes inplace the inverse Fourier transform of the given values over the given ring. The output is in standard order, i.e. the i-th output element is the evaluation of the input at self.root_of_unity()^i, divided by self.len(). Read more
source§

fn unordered_fft<V, S, M, H>(&self, values: V, memory_provider: &M, hom: &H)
where S: RingBase + ?Sized, H: Homomorphism<<<T as FFTTable>::Ring as RingStore>::Type, S>, V: VectorViewMut<<S as RingBase>::Element>, M: MemoryProvider<<S as RingBase>::Element>,

Computes the Fourier transform of the given values, but the output values are arbitrarily permuted (in a way compatible with FFTTable::unordered_inv_fft()). Read more
source§

fn unordered_inv_fft<V, S, M, H>(&self, values: V, memory_provider: &M, hom: &H)
where S: RingBase + ?Sized, H: Homomorphism<<<T as FFTTable>::Ring as RingStore>::Type, S>, V: VectorViewMut<<S as RingBase>::Element>, M: MemoryProvider<<S as RingBase>::Element>,

Inverse to Self::unordered_fft(), with basically the same contract.
source§

impl<R> FiniteRingStore for R
where R: RingStore, <R as RingStore>::Type: FiniteRing,

source§

fn elements<'a>(&'a self) -> <Self::Type as FiniteRing>::ElementsIter<'a>

source§

fn random_element<G: FnMut() -> u64>(&self, rng: G) -> El<Self>

source§

fn size<I: IntegerRingStore>(&self, ZZ: &I) -> Option<El<I>>
where I::Type: IntegerRing,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<'a, S> RingStore for S
where S: Deref, <S as Deref>::Target: RingStore,

§

type Type = <<S as Deref>::Target as RingStore>::Type

source§

fn get_ring<'b>(&'b self) -> &'b <S as RingStore>::Type

source§

fn clone_el(&self, val: &El<Self>) -> El<Self>

source§

fn add_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)

source§

fn add_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)

source§

fn sub_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)

source§

fn sub_self_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)

source§

fn sub_self_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)

source§

fn negate_inplace(&self, lhs: &mut El<Self>)

source§

fn mul_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)

source§

fn mul_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)

source§

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

source§

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

source§

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

source§

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

source§

fn is_zero(&self, value: &El<Self>) -> bool

source§

fn is_one(&self, value: &El<Self>) -> bool

source§

fn is_neg_one(&self, value: &El<Self>) -> bool

source§

fn is_commutative(&self) -> bool

source§

fn is_noetherian(&self) -> bool

source§

fn negate(&self, value: El<Self>) -> El<Self>

source§

fn sub_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn square(&self, value: &mut El<Self>)

source§

fn coerce<S>(&self, from: &S, el: El<S>) -> El<Self>
where S: RingStore, Self::Type: CanHomFrom<S::Type>,

source§

fn into_identity(self) -> Identity<Self>

Returns the identity map self -> self.
source§

fn identity<'a>(&'a self) -> Identity<&'a Self>

Returns the identity map self -> self.
source§

fn into_can_hom<S>(self, from: S) -> Result<CanHom<S, Self>, (S, Self)>
where Self: Sized, S: RingStore, Self::Type: CanHomFrom<S::Type>,

Returns the canonical homomorphism from -> self, if it exists, moving both rings into the CanHom object.
source§

fn into_can_iso<S>(self, from: S) -> Result<CanIso<S, Self>, (S, Self)>
where Self: Sized, S: RingStore, Self::Type: CanIsoFromTo<S::Type>,

Returns the canonical isomorphism from -> self, if it exists, moving both rings into the CanHom object.
source§

fn can_hom<'a, S>(&'a self, from: &'a S) -> Option<CanHom<&'a S, &'a Self>>
where S: RingStore, Self::Type: CanHomFrom<S::Type>,

Returns the canonical homomorphism from -> self, if it exists.
source§

fn can_iso<'a, S>(&'a self, from: &'a S) -> Option<CanIso<&'a S, &'a Self>>
where S: RingStore, Self::Type: CanIsoFromTo<S::Type>,

Returns the canonical isomorphism from -> self, if it exists.
source§

fn into_int_hom(self) -> IntHom<Self>

Returns the homomorphism Z -> self that exists for any ring.
source§

fn int_hom<'a>(&'a self) -> IntHom<&'a Self>

Returns the homomorphism Z -> self that exists for any ring.
source§

fn sum<I>(&self, els: I) -> El<Self>
where I: Iterator<Item = El<Self>>,

source§

fn prod<I>(&self, els: I) -> El<Self>
where I: Iterator<Item = El<Self>>,

source§

fn pow(&self, x: El<Self>, power: usize) -> El<Self>

source§

fn pow_gen<R: IntegerRingStore>( &self, x: El<Self>, power: &El<R>, integers: R ) -> El<Self>
where R::Type: IntegerRing,

source§

fn format<'a>( &'a self, value: &'a El<Self> ) -> RingElementDisplayWrapper<'a, Self>

Returns an object that represents the given ring element and implements std::fmt::Display, to use as formatting parameter. Read more
source§

fn println(&self, value: &El<Self>)

source§

fn characteristic<I: IntegerRingStore>(&self, ZZ: &I) -> Option<El<I>>
where I::Type: IntegerRing,

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<R> ZnRingStore for R
where R: RingStore, <R as RingStore>::Type: ZnRing,