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§
Trait Implementations§
source§impl<R: RingStore> Add for RingElementWrapper<R>
impl<R: RingStore> Add for RingElementWrapper<R>
source§impl<'a, R: RingStore> AddAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
impl<'a, R: RingStore> AddAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
source§fn add_assign(&mut self, rhs: &'a Self)
fn add_assign(&mut self, rhs: &'a Self)
Performs the
+= operation. Read moresource§impl<R: RingStore> AddAssign for RingElementWrapper<R>
impl<R: RingStore> AddAssign for RingElementWrapper<R>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl<R: RingStore> Debug for RingElementWrapper<R>
impl<R: RingStore> Debug for RingElementWrapper<R>
source§impl<R: RingStore> Deref for RingElementWrapper<R>
impl<R: RingStore> Deref for RingElementWrapper<R>
source§impl<R: RingStore> Display for RingElementWrapper<R>
impl<R: RingStore> Display for RingElementWrapper<R>
source§impl<R: RingStore + HashableElRingStore> Hash for RingElementWrapper<R>where
R::Type: HashableElRing,
impl<R: RingStore + HashableElRingStore> Hash for RingElementWrapper<R>where
R::Type: HashableElRing,
source§impl<R: RingStore> Mul for RingElementWrapper<R>
impl<R: RingStore> Mul for RingElementWrapper<R>
source§impl<'a, R: RingStore> MulAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
impl<'a, R: RingStore> MulAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
source§fn mul_assign(&mut self, rhs: &'a Self)
fn mul_assign(&mut self, rhs: &'a Self)
Performs the
*= operation. Read moresource§impl<R: RingStore> MulAssign for RingElementWrapper<R>
impl<R: RingStore> MulAssign for RingElementWrapper<R>
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moresource§impl<R: RingStore> PartialEq for RingElementWrapper<R>
impl<R: RingStore> PartialEq for RingElementWrapper<R>
source§impl<R: RingStore> Sub for RingElementWrapper<R>
impl<R: RingStore> Sub for RingElementWrapper<R>
source§impl<'a, R: RingStore> SubAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
impl<'a, R: RingStore> SubAssign<&'a RingElementWrapper<R>> for RingElementWrapper<R>
source§fn sub_assign(&mut self, rhs: &'a Self)
fn sub_assign(&mut self, rhs: &'a Self)
Performs the
-= operation. Read moresource§impl<R: RingStore> SubAssign for RingElementWrapper<R>
impl<R: RingStore> SubAssign for RingElementWrapper<R>
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl<R: RingStore + Copy> Copy for RingElementWrapper<R>
impl<R: RingStore> Eq for RingElementWrapper<R>
Auto Trait Implementations§
impl<R> Freeze for RingElementWrapper<R>
impl<R> RefUnwindSafe for RingElementWrapper<R>
impl<R> Send for RingElementWrapper<R>
impl<R> Sync for RingElementWrapper<R>
impl<R> Unpin for RingElementWrapper<R>
impl<R> UnwindSafe for RingElementWrapper<R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<R> DivisibilityRingStore for R
impl<R> DivisibilityRingStore for R
source§impl<R> ExtensionFieldStore for R
impl<R> ExtensionFieldStore for R
source§fn into_hom<T, H>(
self,
target: T,
base_ring_hom: H
) -> Result<ExtensionFieldEmbedding<Self, T, H>, (Self, T)>where
T: RingStore,
T::Type: ExtensionField,
H: Homomorphism<<<Self::Type as RingExtension>::BaseRing as RingStore>::Type, <<T::Type as RingExtension>::BaseRing as RingStore>::Type>,
fn into_hom<T, H>(
self,
target: T,
base_ring_hom: H
) -> Result<ExtensionFieldEmbedding<Self, T, H>, (Self, T)>where
T: RingStore,
T::Type: ExtensionField,
H: Homomorphism<<<Self::Type as RingExtension>::BaseRing as RingStore>::Type, <<T::Type as RingExtension>::BaseRing as RingStore>::Type>,
source§fn has_hom<'a, T>(
&'a self,
target: &'a T
) -> Option<ExtensionFieldEmbedding<&'a Self, &'a T, Identity<&'a <Self::Type as RingExtension>::BaseRing>>>where
T: RingStore,
T::Type: ExtensionField,
<T::Type as RingExtension>::BaseRing: RingStore<Type = <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
fn has_hom<'a, T>(
&'a self,
target: &'a T
) -> Option<ExtensionFieldEmbedding<&'a Self, &'a T, Identity<&'a <Self::Type as RingExtension>::BaseRing>>>where
T: RingStore,
T::Type: ExtensionField,
<T::Type as RingExtension>::BaseRing: RingStore<Type = <<Self::Type as RingExtension>::BaseRing as RingStore>::Type>,
fn galois_group<'a>(&'a self) -> Option<Vec<GaloisAutomorphism<&'a Self>>>
source§impl<T> FFTTable for T
impl<T> FFTTable for T
type Ring = <<T as Deref>::Target as FFTTable>::Ring
source§fn ring(&self) -> &<T as FFTTable>::Ring
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
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 moresource§fn unordered_fft_permutation(&self, i: usize) -> usize
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
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)where
S: RingBase + ?Sized,
H: Homomorphism<<<T as FFTTable>::Ring as RingStore>::Type, S>,
V: SwappableVectorViewMut<<S as RingBase>::Element>,
M: MemoryProvider<<S as RingBase>::Element>,
fn 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: SwappableVectorViewMut<<S as RingBase>::Element>,
M: MemoryProvider<<S as RingBase>::Element>,
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 moresource§fn 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: SwappableVectorViewMut<<S as RingBase>::Element>,
M: MemoryProvider<<S as RingBase>::Element>,
fn 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: SwappableVectorViewMut<<S as RingBase>::Element>,
M: MemoryProvider<<S as RingBase>::Element>,
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 moresource§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>,
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 moresource§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>,
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
impl<R> FiniteRingStore for R
fn elements<'a>(&'a self) -> <Self::Type as FiniteRing>::ElementsIter<'a>
fn random_element<G: FnMut() -> u64>(&self, rng: G) -> El<Self>
fn size<I: IntegerRingStore>(&self, ZZ: &I) -> Option<El<I>>where
I::Type: IntegerRing,
source§impl<'a, S> RingStore for S
impl<'a, S> RingStore for S
type Type = <<S as Deref>::Target as RingStore>::Type
fn get_ring<'b>(&'b self) -> &'b <S as RingStore>::Type
source§fn add_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
fn add_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
source§fn add_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
fn add_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
source§fn sub_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
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>)
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>)
fn sub_self_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
source§fn negate_inplace(&self, lhs: &mut El<Self>)
fn negate_inplace(&self, lhs: &mut El<Self>)
source§fn mul_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
fn mul_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
source§fn mul_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
fn mul_assign_ref(&self, lhs: &mut El<Self>, rhs: &El<Self>)
source§fn zero(&self) -> El<Self>
fn zero(&self) -> El<Self>
See
RingBase::zero()source§fn one(&self) -> El<Self>
fn one(&self) -> El<Self>
See
RingBase::one()source§fn is_neg_one(&self, value: &El<Self>) -> bool
fn is_neg_one(&self, value: &El<Self>) -> bool
source§fn is_commutative(&self) -> bool
fn is_commutative(&self) -> bool
source§fn is_noetherian(&self) -> bool
fn is_noetherian(&self) -> bool
source§fn sub_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
fn sub_assign(&self, lhs: &mut El<Self>, rhs: El<Self>)
fn coerce<S>(&self, from: &S, el: El<S>) -> El<Self>
source§fn into_identity(self) -> Identity<Self>
fn into_identity(self) -> Identity<Self>
Returns the identity map
self -> self.source§fn into_can_hom<S>(self, from: S) -> Result<CanHom<S, Self>, (S, Self)>
fn into_can_hom<S>(self, from: S) -> Result<CanHom<S, Self>, (S, Self)>
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)>
fn into_can_iso<S>(self, from: S) -> Result<CanIso<S, Self>, (S, Self)>
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>>
fn can_hom<'a, S>(&'a self, from: &'a S) -> Option<CanHom<&'a S, &'a Self>>
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>>
fn can_iso<'a, S>(&'a self, from: &'a S) -> Option<CanIso<&'a S, &'a Self>>
Returns the canonical isomorphism
from -> self, if it exists.source§fn into_int_hom(self) -> IntHom<Self>
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>
fn int_hom<'a>(&'a self) -> IntHom<&'a Self>
Returns the homomorphism
Z -> self that exists for any ring.fn sum<I>(&self, els: I) -> El<Self>
fn prod<I>(&self, els: I) -> El<Self>
fn pow(&self, x: El<Self>, power: usize) -> El<Self>
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>
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