pub struct NTTConvolution<R_main, R_twiddle, H, A = Global>where
R_main: ?Sized + ZnRing,
R_twiddle: ?Sized + ZnRing,
H: Homomorphism<R_twiddle, R_main> + Clone,
A: Allocator + Clone,{ /* private fields */ }
unstable-enable
only.Expand description
Computes the convolution over a finite field that has suitable roots of unity using a power-of-two length FFT (sometimes called Number-Theoretic Transform, NTT in this context).
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Implementations§
Source§impl<R> NTTConvolution<R::Type, R::Type, Identity<R>>
impl<R> NTTConvolution<R::Type, R::Type, Identity<R>>
Sourcepub fn new(ring: R) -> Self
pub fn new(ring: R) -> Self
Creates a new NTTConvolution
.
Note that this convolution will be able to compute convolutions whose output is
of length <= n
, where n
is the largest power of two such that the given ring
has a primitive n
-th root of unity.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Source§impl<R_main, R_twiddle, H, A> NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> NTTConvolution<R_main, R_twiddle, H, A>
Sourcepub fn new_with_hom(hom: H, allocator: A) -> Self
pub fn new_with_hom(hom: H, allocator: A) -> Self
Creates a new NTTConvolution
.
Note that this convolution will be able to compute convolutions whose output is
of length <= n
, where n
is the largest power of two such that the domain of
the given homomorphism has a primitive n
-th root of unity.
Internally, twiddle factors for the underlying NTT will be stored as elements of
the domain of the given homomorphism, while the convolutions are performed over the
codomain. This can be used for more efficient NTTs, see e.g. zn_64::ZnFastmul
.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn ring(&self) -> RingRef<'_, R_main>
pub fn ring(&self) -> RingRef<'_, R_main>
Returns the ring over which this object can compute convolutions.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Trait Implementations§
Source§impl<R_main, R_twiddle, H, A> ConvolutionAlgorithm<R_main> for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> ConvolutionAlgorithm<R_main> for NTTConvolution<R_main, R_twiddle, H, A>
Source§type PreparedConvolutionOperand = PreparedConvolutionOperand<R_main, A>
type PreparedConvolutionOperand = PreparedConvolutionOperand<R_main, A>
Source§fn supports_ring<S: RingStore<Type = R_main> + Copy>(&self, ring: S) -> bool
fn supports_ring<S: RingStore<Type = R_main> + Copy>(&self, ring: S) -> bool
Source§fn compute_convolution<S: RingStore<Type = R_main> + Copy, V1: VectorView<<R_main as RingBase>::Element>, V2: VectorView<<R_main as RingBase>::Element>>(
&self,
lhs: V1,
rhs: V2,
dst: &mut [R_main::Element],
ring: S,
)
fn compute_convolution<S: RingStore<Type = R_main> + Copy, V1: VectorView<<R_main as RingBase>::Element>, V2: VectorView<<R_main as RingBase>::Element>>( &self, lhs: V1, rhs: V2, dst: &mut [R_main::Element], ring: S, )
Source§fn prepare_convolution_operand<S, V>(
&self,
val: V,
length_hint: Option<usize>,
ring: S,
) -> Self::PreparedConvolutionOperand
fn prepare_convolution_operand<S, V>( &self, val: V, length_hint: Option<usize>, ring: S, ) -> Self::PreparedConvolutionOperand
ConvolutionAlgorithm::PreparedConvolutionOperand
,
which can be used to compute future convolutions with this list of values faster. Read moreSource§fn compute_convolution_prepared<S, V1, V2>(
&self,
lhs: V1,
lhs_prep: Option<&Self::PreparedConvolutionOperand>,
rhs: V2,
rhs_prep: Option<&Self::PreparedConvolutionOperand>,
dst: &mut [R_main::Element],
ring: S,
)where
S: RingStore<Type = R_main> + Copy,
V1: VectorView<R_main::Element>,
V2: VectorView<R_main::Element>,
fn compute_convolution_prepared<S, V1, V2>(
&self,
lhs: V1,
lhs_prep: Option<&Self::PreparedConvolutionOperand>,
rhs: V2,
rhs_prep: Option<&Self::PreparedConvolutionOperand>,
dst: &mut [R_main::Element],
ring: S,
)where
S: RingStore<Type = R_main> + Copy,
V1: VectorView<R_main::Element>,
V2: VectorView<R_main::Element>,
lhs
and rhs
to dst
. If provided, the given
prepared convolution operands are used for a faster computation. Read moreSource§fn compute_convolution_sum<'a, S, I, V1, V2>(
&self,
values: I,
dst: &mut [R_main::Element],
ring: S,
)where
S: RingStore<Type = R_main> + Copy,
I: ExactSizeIterator<Item = (V1, Option<&'a Self::PreparedConvolutionOperand>, V2, Option<&'a Self::PreparedConvolutionOperand>)>,
V1: VectorView<R_main::Element>,
V2: VectorView<R_main::Element>,
Self: 'a,
R_main: 'a,
fn compute_convolution_sum<'a, S, I, V1, V2>(
&self,
values: I,
dst: &mut [R_main::Element],
ring: S,
)where
S: RingStore<Type = R_main> + Copy,
I: ExactSizeIterator<Item = (V1, Option<&'a Self::PreparedConvolutionOperand>, V2, Option<&'a Self::PreparedConvolutionOperand>)>,
V1: VectorView<R_main::Element>,
V2: VectorView<R_main::Element>,
Self: 'a,
R_main: 'a,
dst
. Read moreAuto Trait Implementations§
impl<R_main, R_twiddle, H, A = Global> !Freeze for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A = Global> !RefUnwindSafe for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> Send for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> Sync for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> Unpin for NTTConvolution<R_main, R_twiddle, H, A>
impl<R_main, R_twiddle, H, A> UnwindSafe for NTTConvolution<R_main, R_twiddle, H, A>where
H: UnwindSafe + RefUnwindSafe,
A: UnwindSafe,
<R_main as RingBase>::Element: RefUnwindSafe + UnwindSafe,
<R_twiddle as RingBase>::Element: RefUnwindSafe + UnwindSafe,
R_main: ?Sized,
R_twiddle: ?Sized,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more