pub struct ComplexFFTBasedRingBase<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> { /* private fields */ }
Expand description

Implementation of rings Z[X]/(f(X), q) that uses a GeneralizedFFT for fast arithmetic.

The concrete ring (i.e. the polynomial f) is determined by the used GeneralizedFFT. In the most general case, you can use ComplexFFTBasedRingBase::from_generalized_fft() to create an instance for any f, but in the case of cyclotomics (e.g. when using crate::complexfft::pow2_cyclotomic::Pow2CyclotomicFFT), simpler creation functions are provided.

§Example

type TheRing = ComplexFFTBasedRing<Pow2CyclotomicFFT<Zn, cooley_tuckey::FFTTableCooleyTuckey<Complex64>>, DefaultMemoryProvider, DefaultMemoryProvider>;
 
// the ring `F7[X]/(X^8 + 1)`
let R = <TheRing as RingStore>::Type::new(Zn::new(7), 3, default_memory_provider!(), default_memory_provider!());
let root_of_unity = R.canonical_gen();
assert_eq!(8, R.rank());
assert_eq!(16, R.n());
assert_el_eq!(&R, &R.neg_one(), &R.pow(root_of_unity, 8));
 
// instead of this, we can also explicity create the `GeneralizedFFT`
let generalized_fft: Pow2CyclotomicFFT<Zn, cooley_tuckey::FFTTableCooleyTuckey<Complex64>> = Pow2CyclotomicFFT::create(
    Zn::new(7),
    cooley_tuckey::FFTTableCooleyTuckey::for_complex(Complex64::RING, 3)
);
let R = RingValue::from(<TheRing as RingStore>::Type::from_generalized_fft(generalized_fft, default_memory_provider!(), default_memory_provider!()));
assert_eq!(8, R.rank());
assert_eq!(16, R.n());
assert_el_eq!(&R, &R.neg_one(), &R.pow(R.canonical_gen(), 8));

Implementations§

source§

impl<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> ComplexFFTBasedRingBase<F, M_Zn, M_CC>

source

pub fn from_generalized_fft( data: F, memory_provider_zn: M_Zn, memory_provider_cc: M_CC, ) -> Self

source

pub fn generalized_fft(&self) -> &F

source

pub fn memory_provider_zn(&self) -> &M_Zn

source

pub fn memory_provider_cc(&self) -> &M_CC

source§

impl<R: ZnRingStore, M_Zn, M_CC> ComplexFFTBasedRingBase<Pow2CyclotomicFFT<R, FFTTableCooleyTuckey<Complex64>>, M_Zn, M_CC>
where R::Type: ZnRing, M_Zn: MemoryProvider<El<R>>, M_CC: MemoryProvider<Complex64El>,

source

pub fn new( base_ring: R, log2_ring_degree: usize, memory_provider_zn: M_Zn, memory_provider_cc: M_CC, ) -> RingValue<Self>

source§

impl<R, M_Zn, M_CC> ComplexFFTBasedRingBase<OddCyclotomicFFT<R, FFTTableBluestein<Complex64>>, M_Zn, M_CC>

source

pub fn new( base_ring: R, n: usize, memory_provider_zn: M_Zn, memory_provider_cc: M_CC, ) -> RingValue<Self>

Trait Implementations§

source§

impl<F1, F2, M1_Zn, M2_Zn, M1_CC, M2_CC> CanHomFrom<ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>> for ComplexFFTBasedRingBase<F1, M1_Zn, M1_CC>

§

type Homomorphism = <<F1 as GeneralizedFFT>::BaseRingBase as CanHomFrom<<F2 as GeneralizedFFT>::BaseRingBase>>::Homomorphism

source§

fn has_canonical_hom( &self, from: &ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>, ) -> Option<Self::Homomorphism>

source§

fn map_in( &self, from: &ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>, el: <ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC> as RingBase>::Element, hom: &Self::Homomorphism, ) -> Self::Element

source§

fn map_in_ref( &self, from: &S, el: &<S as RingBase>::Element, hom: &Self::Homomorphism, ) -> Self::Element

source§

fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: <S as RingBase>::Element, hom: &Self::Homomorphism, )

source§

fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &<S as RingBase>::Element, hom: &Self::Homomorphism, )

source§

impl<P, F, M_Zn, M_CC> CanHomFrom<P> for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

§

type Homomorphism = <<F as GeneralizedFFT>::BaseRingBase as CanHomFrom<<<P as RingExtension>::BaseRing as RingStore>::Type>>::Homomorphism

source§

fn has_canonical_hom(&self, from: &P) -> Option<Self::Homomorphism>

source§

fn map_in( &self, from: &P, el: <P as RingBase>::Element, hom: &Self::Homomorphism, ) -> Self::Element

source§

fn map_in_ref( &self, from: &P, el: &<P as RingBase>::Element, hom: &Self::Homomorphism, ) -> Self::Element

source§

fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: <S as RingBase>::Element, hom: &Self::Homomorphism, )

source§

fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &<S as RingBase>::Element, hom: &Self::Homomorphism, )

source§

impl<F1, F2, M1_Zn, M2_Zn, M1_CC, M2_CC> CanIsoFromTo<ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>> for ComplexFFTBasedRingBase<F1, M1_Zn, M1_CC>

§

type Isomorphism = <<F1 as GeneralizedFFT>::BaseRingBase as CanIsoFromTo<<F2 as GeneralizedFFT>::BaseRingBase>>::Isomorphism

source§

fn has_canonical_iso( &self, from: &ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>, ) -> Option<Self::Isomorphism>

source§

fn map_out( &self, from: &ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC>, el: Self::Element, iso: &Self::Isomorphism, ) -> <ComplexFFTBasedRingBase<F2, M2_Zn, M2_CC> as RingBase>::Element

source§

impl<R: ZnRingStore, F: FFTTable<Ring = Complex64> + ErrorEstimate, M_Zn, M_CC> CyclotomicRing for ComplexFFTBasedRingBase<OddCyclotomicFFT<R, F>, M_Zn, M_CC>

source§

fn n(&self) -> usize

The cyclotomic order, i.e. the multiplicative order of self.canonical_gen(). The degree of this ring extension is phi(self.n()) where phi is Euler’s totient function.
source§

impl<R: ZnRingStore, F: FFTTable<Ring = Complex64> + ErrorEstimate, M_Zn, M_CC> CyclotomicRing for ComplexFFTBasedRingBase<Pow2CyclotomicFFT<R, F>, M_Zn, M_CC>
where R::Type: ZnRing, M_Zn: MemoryProvider<El<R>>, M_CC: MemoryProvider<Complex64El>,

source§

fn n(&self) -> usize

The cyclotomic order, i.e. the multiplicative order of self.canonical_gen(). The degree of this ring extension is phi(self.n()) where phi is Euler’s totient function.
source§

impl<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> FiniteRing for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

§

type ElementsIter<'a> = MultiProduct<<<F as GeneralizedFFT>::BaseRingBase as FiniteRing>::ElementsIter<'a>, WRTCanonicalBasisElementCreator<'a, F, M_Zn, M_CC>, RingElementClone<'a, <F as GeneralizedFFT>::BaseRingBase>, <ComplexFFTBasedRingBase<F, M_Zn, M_CC> as RingBase>::Element> where Self: 'a

source§

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

source§

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

source§

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

source§

impl<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> FreeAlgebra for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

§

type VectorRepresentation<'a> = RingElVectorViewFn<&'a <F as GeneralizedFFT>::BaseRingStore, &'a [<<<F as GeneralizedFFT>::BaseRingStore as RingStore>::Type as RingBase>::Element], <<<F as GeneralizedFFT>::BaseRingStore as RingStore>::Type as RingBase>::Element> where Self: 'a

source§

fn canonical_gen(&self) -> Self::Element

source§

fn rank(&self) -> usize

source§

fn wrt_canonical_basis<'a>( &'a self, el: &'a Self::Element, ) -> Self::VectorRepresentation<'a>

source§

fn from_canonical_basis<V>(&self, vec: V) -> Self::Element

source§

impl<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> PartialEq for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

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<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> RingBase for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

§

type Element = <M_Zn as MemoryProvider<<<<F as GeneralizedFFT>::BaseRingStore as RingStore>::Type as RingBase>::Element>>::Object

source§

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

source§

fn add_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

source§

fn add_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

source§

fn sub_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

source§

fn negate_inplace(&self, lhs: &mut Self::Element)

source§

fn mul_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

source§

fn mul_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

source§

fn from_int(&self, value: i32) -> Self::Element

source§

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

source§

fn is_commutative(&self) -> bool

source§

fn is_noetherian(&self) -> bool

source§

fn dbg<'a>(&self, value: &Self::Element, out: &mut Formatter<'a>) -> Result

source§

fn square(&self, value: &mut Self::Element)

source§

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

Raises x to the power of an arbitrary, nonnegative integer given by a custom integer ring implementation. Read more
source§

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

Returns the characteristic of this ring as an element of the given implementation of ZZ. Read more
source§

fn zero(&self) -> Self::Element

source§

fn one(&self) -> Self::Element

source§

fn neg_one(&self) -> Self::Element

source§

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

source§

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

source§

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

source§

fn is_approximate(&self) -> bool

Returns whether this ring computes with approximations to elements. This would usually be the case for rings that are based on f32 or f64, to represent real or complex numbers. Read more
source§

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

source§

fn sub_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

source§

fn mul_assign_int(&self, lhs: &mut Self::Element, rhs: i32)

source§

fn mul_int(&self, lhs: Self::Element, rhs: i32) -> Self::Element

source§

fn mul_int_ref(&self, lhs: &Self::Element, rhs: i32) -> Self::Element

source§

fn sub_self_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

Computes lhs := rhs - lhs.
source§

fn sub_self_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

Computes lhs := rhs - lhs.
source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<F: GeneralizedFFT + GeneralizedFFTSelfIso, M_Zn: MemoryProvider<El<F::BaseRingStore>>, M_CC: MemoryProvider<Complex64El>> RingExtension for ComplexFFTBasedRingBase<F, M_Zn, M_CC>

§

type BaseRing = <F as GeneralizedFFT>::BaseRingStore

source§

fn base_ring<'a>(&'a self) -> &'a Self::BaseRing

source§

fn from(&self, x: El<Self::BaseRing>) -> Self::Element

source§

fn from_ref( &self, x: &<<Self::BaseRing as RingStore>::Type as RingBase>::Element, ) -> Self::Element

source§

fn mul_assign_base( &self, lhs: &mut Self::Element, rhs: &<<Self::BaseRing as RingStore>::Type as RingBase>::Element, )

Computes lhs := lhs * rhs, where rhs is mapped into this ring via RingExtension::from_ref(). Note that this may be faster than self.mul_assign(lhs, self.from_ref(rhs)).

Auto Trait Implementations§

§

impl<F, M_Zn, M_CC> Freeze for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: Freeze, M_Zn: Freeze, M_CC: Freeze,

§

impl<F, M_Zn, M_CC> RefUnwindSafe for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: RefUnwindSafe, M_Zn: RefUnwindSafe, M_CC: RefUnwindSafe,

§

impl<F, M_Zn, M_CC> Send for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: Send, M_Zn: Send, M_CC: Send,

§

impl<F, M_Zn, M_CC> Sync for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: Sync, M_Zn: Sync, M_CC: Sync,

§

impl<F, M_Zn, M_CC> Unpin for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: Unpin, M_Zn: Unpin, M_CC: Unpin,

§

impl<F, M_Zn, M_CC> UnwindSafe for ComplexFFTBasedRingBase<F, M_Zn, M_CC>
where F: UnwindSafe, M_Zn: UnwindSafe, M_CC: 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> ConvMulComputation for R
where R: RingBase + ?Sized,

source§

default fn karatsuba_threshold(&self) -> usize

Define a threshold from which on the default implementation of ConvMulComputation::add_assign_conv_mul() will use the Karatsuba algorithm. Read more
source§

fn add_assign_conv_mul<M>( &self, dst: &mut [<R as RingBase>::Element], lhs: &[<R as RingBase>::Element], rhs: &[<R as RingBase>::Element], memory_provider: &M, )
where M: MemoryProvider<<R as RingBase>::Element>,

Computes the convolution of lhs and rhs, and adds the result to dst. Read more
source§

impl<R, S> CooleyTuckeyButterfly<S> for R
where S: RingBase + ?Sized, R: RingBase + ?Sized,

source§

default fn butterfly<V, H>( &self, hom: &H, values: &mut V, twiddle: &<S as RingBase>::Element, i1: usize, i2: usize, )
where V: VectorViewMut<<R as RingBase>::Element>, H: Homomorphism<S, R>,

Should compute (values[i1], values[i2]) := (values[i1] + twiddle * values[i2], values[i1] - twiddle * values[i2])
source§

default fn inv_butterfly<V, H>( &self, hom: &H, values: &mut V, twiddle: &<S as RingBase>::Element, i1: usize, i2: usize, )
where V: VectorViewMut<<R as RingBase>::Element>, H: Homomorphism<S, R>,

Should compute (values[i1], values[i2]) := (values[i1] + values[i2], (values[i1] - values[i2]) * twiddle)
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<R> InnerProductComputation for R
where R: RingBase + ?Sized,

source§

default fn inner_product_ref_fst<'a, I>( &self, els: I, ) -> <R as RingBase>::Element
where I: Iterator<Item = (&'a <R as RingBase>::Element, <R as RingBase>::Element)>, <R as RingBase>::Element: 'a,

Computes the inner product sum_i lhs[i] * rhs[i].
source§

default fn inner_product_ref<'a, I>(&self, els: I) -> <R as RingBase>::Element
where I: Iterator<Item = (&'a <R as RingBase>::Element, &'a <R as RingBase>::Element)>, <R as RingBase>::Element: 'a,

Computes the inner product sum_i lhs[i] * rhs[i].
source§

default fn inner_product<I>(&self, els: I) -> <R as RingBase>::Element
where I: Iterator<Item = (<R as RingBase>::Element, <R as RingBase>::Element)>,

Computes the inner product sum_i lhs[i] * rhs[i].
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, 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> SelfIso for R
where R: CanIsoFromTo<R> + ?Sized,