Struct feanor_math::ring::RingValue

source ·
pub struct RingValue<R: RingBase> { /* private fields */ }
Expand description

The most fundamental crate::ring::RingStore. It is basically a no-op container, i.e. stores a crate::ring::RingBase object by value, and allows accessing it.

§Why is this necessary?

In fact, that we need this trait is just the result of a technical detail. We cannot implement

impl<R: RingBase> RingStore for R {}
impl<'a, R: RingStore> RingStore for &;a R {}

since this might cause conflicting implementations. Instead, we implement

impl<R: RingBase> RingStore for RingValue<R> {}
impl<'a, R: RingStore> RingStore for &;a R {}

This causes some inconvenience, as now we cannot chain crate::ring::RingStore in the case of crate::ring::RingValue. Furthermore, this trait will be necessary everywhere - to define a reference to a ring of type A, we now have to write &RingValue<A>.

To simplify this, we propose to use the following simple pattern: Create your ring type as

struct ABase { ... }
impl RingBase for ABase { ... } 

and then provide a type alias

type A = RingValue<ABase>;

Implementations§

source§

impl<R: RingBase> RingValue<R>

source

pub const fn from(value: R) -> Self

source§

impl<T: PrimitiveInt> RingValue<StaticRingBase<T>>

source

pub const RING: StaticRing<T> = _

source§

impl RingValue<RustBigintRingBase>

source

pub const RING: RustBigintRing = _

source§

impl<I: IntegerRingStore> RingValue<ZnBase<I>>
where I::Type: IntegerRing,

source

pub fn new(integer_ring: I, modulus: El<I>) -> Self

source§

impl RingValue<ZnBase>

source

pub fn new(modulus: u64) -> Self

👎Deprecated since 1.6.1: Please use use zn_64 instead
source§

impl RingValue<ZnFastmulBase>

source

pub fn new(base: Zn) -> Self

👎Deprecated since 1.6.1: Please use use zn_64 instead
source§

impl RingValue<ZnBase>

source

pub fn new(modulus: u64) -> Self

source§

impl RingValue<ZnFastmulBase>

source

pub fn new(base: Zn) -> Self

source§

impl<const N: u64, const IS_FIELD: bool> RingValue<ZnBase<N, IS_FIELD>>

source

pub const RING: Self = _

source§

impl<J: IntegerRingStore> RingValue<ZnBase<RingValue<ZnBase>, J>>

source

pub fn from_primes(large_integers: J, primes: Vec<u64>) -> Self

source§

impl<J: IntegerRingStore> RingValue<ZnBase<RingValue<ZnBase>, J>>

source

pub fn create_from_primes(large_integers: J, primes: Vec<u64>) -> Self

source§

impl<C: ZnRingStore, J: IntegerRingStore, M: MemoryProvider<El<C>>> RingValue<ZnBase<C, J, M>>

source

pub fn new(summands: Vec<C>, large_integers: J, memory_provider: M) -> Self

Creates a new ring for Z/nZ with n = m1 ... mr where the mi are the moduli of the given component rings. Furthermore, the corresponding large integer ring must be provided, which has to be able to store values of size at least n^3.

source§

impl<R: RingStore> RingValue<DensePolyRingBase<R>>

source

pub fn new(base_ring: R, unknown_name: &'static str) -> Self

source§

impl<R: RingStore> RingValue<SparsePolyRingBase<R>>

source

pub fn new(base_ring: R, unknown_name: &'static str) -> Self

source§

impl RingValue<Complex64Base>

source

pub const RING: Self = _

source

pub const I: Complex64El = _

source§

impl RingValue<Complex64Base>

source

pub fn abs(&self, val: Complex64El) -> f64

source

pub fn conjugate(&self, val: Complex64El) -> Complex64El

source

pub fn exp(&self, exp: Complex64El) -> Complex64El

source

pub fn closest_gaussian_int(&self, val: Complex64El) -> (i64, i64)

source

pub fn ln_main_branch(&self, val: Complex64El) -> Complex64El

source

pub fn is_absolute_approx_eq( &self, lhs: Complex64El, rhs: Complex64El, absolute_threshold: f64, ) -> bool

source

pub fn is_relative_approx_eq( &self, lhs: Complex64El, rhs: Complex64El, relative_limit: f64, ) -> bool

source

pub fn is_approx_eq( &self, lhs: Complex64El, rhs: Complex64El, precision: u64, ) -> bool

source

pub fn from_f64(&self, x: f64) -> Complex64El

source

pub fn root_of_unity(&self, i: i64, n: i64) -> Complex64El

source

pub fn re(&self, x: Complex64El) -> f64

source

pub fn im(&self, x: Complex64El) -> f64

source§

impl RingValue<Real64Base>

source§

impl<R, V, M> RingValue<FreeAlgebraImplBase<R, V, M>>
where R: RingStore, V: VectorView<El<R>>, M: MemoryProvider<El<R>>,

source

pub const fn new( base_ring: R, x_pow_rank: V, memory_provider: M, ) -> FreeAlgebraImpl<R, V, M>

source§

impl<R, V, M> RingValue<FreeAlgebraImplBase<R, V, M>>

source

pub fn as_field(self) -> Result<AsField<Self>, Self>

source§

impl<R, O, M, const N: usize> RingValue<MultivariatePolyRingImplBase<R, O, M, N>>

source

pub fn new(base_ring: R, monomial_order: O, memory_provider: M) -> Self

source§

impl<I> RingValue<RationalFieldBase<I>>

source

pub const fn new(integers: I) -> Self

Trait Implementations§

source§

impl<R: Clone + RingBase> Clone for RingValue<R>

source§

fn clone(&self) -> RingValue<R>

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: RingBase> RingStore for RingValue<R>

§

type Type = R

source§

fn get_ring(&self) -> &R

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<R: Copy + RingBase> Copy for RingValue<R>

Auto Trait Implementations§

§

impl<R> Freeze for RingValue<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for RingValue<R>
where R: RefUnwindSafe,

§

impl<R> Send for RingValue<R>
where R: Send,

§

impl<R> Sync for RingValue<R>
where R: Sync,

§

impl<R> Unpin for RingValue<R>
where R: Unpin,

§

impl<R> UnwindSafe for RingValue<R>
where R: UnwindSafe,

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

source§

fn integer_ring(&self) -> &<Self::Type as ZnRing>::Integers

source§

fn modulus(&self) -> &El<<Self::Type as ZnRing>::Integers>

source§

fn smallest_positive_lift( &self, el: El<Self>, ) -> El<<Self::Type as ZnRing>::Integers>

source§

fn smallest_lift(&self, el: El<Self>) -> El<<Self::Type as ZnRing>::Integers>

source§

fn any_lift(&self, el: El<Self>) -> El<<Self::Type as ZnRing>::Integers>

source§

fn is_field(&self) -> bool

source§

fn as_field(self) -> Result<RingValue<AsFieldBase<Self>>, Self>
where Self: Sized,