pub struct RNSConvolution<I = BigIntRing, C = NTTConvolution<ZnBase, ZnFastmulBase, CanHom<ZnFastmul, Zn>>, A = Global, CreateC = CreateNTTConvolution>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,{ /* private fields */ }
unstable-enable
only.Expand description
A ConvolutionAlgorithm
that computes convolutions by computing them modulo a
suitable composite modulus q
, whose factors are of a certain shape, usually such
as to allow for NTT-based convolutions.
Due to overlapping blanket impls, this type can only be used to compute convolutions
over IntegerRing
s. For computing convolutions over ZnRing
s, wrap it in a
RNSConvolutionZn
.
§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 RNSConvolution
impl RNSConvolution
Sourcepub fn new(max_log2_n: usize) -> Self
pub fn new(max_log2_n: usize) -> Self
Creates a new RNSConvolution
that can compute convolutions of sequences with output
length <= 2^max_log2_n
. As base convolution, the NTTConvolution
is used.
§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<I, C, A, CreateC> RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
impl<I, C, A, CreateC> RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
Sourcepub fn new_with_convolution(
required_root_of_unity_log2: usize,
max_prime_size_log2: usize,
integer_ring: I,
allocator: A,
create_convolution: CreateC,
) -> Self
pub fn new_with_convolution( required_root_of_unity_log2: usize, max_prime_size_log2: usize, integer_ring: I, allocator: A, create_convolution: CreateC, ) -> Self
Creates a new RNSConvolution
with all the given configuration parameters.
In particular
required_root_of_unity_log2
andmax_prime_size_log2
control which prime factors are used for the underlying composite modulus; Only primes<= 2^max_prime_size_log2
and= 1
modrequired_root_of_unity_log2
are sampledinteger_ring
is the ring to store intermediate lifts in; this probably has to beBigIntRing
, unless inputs are pretty smallallocator
is used to allocate elements modulo the internal modulus, as elements ofzn_rns::Zn
create_convolution
is called whenever a new convolution algorithm for a new prime has to be created; the modulus of the givenZn
always satisfies the constraints defined bymax_prime_size_log2
andrequired_root_of_unity_log2
§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, I, C, A, CreateC> ConvolutionAlgorithm<R> for RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
R: ?Sized + IntegerRing,
impl<R, I, C, A, CreateC> ConvolutionAlgorithm<R> for RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
R: ?Sized + IntegerRing,
Source§type PreparedConvolutionOperand = PreparedConvolutionOperand<R, C>
type PreparedConvolutionOperand = PreparedConvolutionOperand<R, C>
Source§fn compute_convolution<S: RingStore<Type = R> + Copy, V1: VectorView<<R as RingBase>::Element>, V2: VectorView<<R as RingBase>::Element>>(
&self,
lhs: V1,
rhs: V2,
dst: &mut [<R as RingBase>::Element],
ring: S,
)
fn compute_convolution<S: RingStore<Type = R> + Copy, V1: VectorView<<R as RingBase>::Element>, V2: VectorView<<R as RingBase>::Element>>( &self, lhs: V1, rhs: V2, dst: &mut [<R as RingBase>::Element], ring: S, )
Source§fn supports_ring<S: RingStore<Type = R> + Copy>(&self, _ring: S) -> bool
fn supports_ring<S: RingStore<Type = R> + Copy>(&self, _ring: S) -> bool
Source§fn prepare_convolution_operand<S, V>(
&self,
val: V,
len_hint: Option<usize>,
ring: S,
) -> Self::PreparedConvolutionOperand
fn prepare_convolution_operand<S, V>( &self, val: V, len_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::Element],
ring: S,
)
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::Element], ring: S, )
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, J, V1, V2>(
&self,
values: J,
dst: &mut [R::Element],
ring: S,
)where
S: RingStore<Type = R> + Copy,
J: ExactSizeIterator<Item = (V1, Option<&'a Self::PreparedConvolutionOperand>, V2, Option<&'a Self::PreparedConvolutionOperand>)>,
V1: VectorView<R::Element>,
V2: VectorView<R::Element>,
Self: 'a,
R: 'a,
fn compute_convolution_sum<'a, S, J, V1, V2>(
&self,
values: J,
dst: &mut [R::Element],
ring: S,
)where
S: RingStore<Type = R> + Copy,
J: ExactSizeIterator<Item = (V1, Option<&'a Self::PreparedConvolutionOperand>, V2, Option<&'a Self::PreparedConvolutionOperand>)>,
V1: VectorView<R::Element>,
V2: VectorView<R::Element>,
Self: 'a,
R: 'a,
dst
. Read moreSource§impl<'a, I, C, A, CreateC> From<&'a RNSConvolution<I, C, A, CreateC>> for &'a RNSConvolutionZn<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
impl<'a, I, C, A, CreateC> From<&'a RNSConvolution<I, C, A, CreateC>> for &'a RNSConvolutionZn<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
Source§fn from(value: &'a RNSConvolution<I, C, A, CreateC>) -> Self
fn from(value: &'a RNSConvolution<I, C, A, CreateC>) -> Self
Source§impl<'a, I, C, A, CreateC> From<&'a RNSConvolutionZn<I, C, A, CreateC>> for &'a RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
impl<'a, I, C, A, CreateC> From<&'a RNSConvolutionZn<I, C, A, CreateC>> for &'a RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
Source§fn from(value: &'a RNSConvolutionZn<I, C, A, CreateC>) -> Self
fn from(value: &'a RNSConvolutionZn<I, C, A, CreateC>) -> Self
Source§impl<I, C, A, CreateC> From<RNSConvolution<I, C, A, CreateC>> for RNSConvolutionZn<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
impl<I, C, A, CreateC> From<RNSConvolution<I, C, A, CreateC>> for RNSConvolutionZn<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
Source§fn from(value: RNSConvolution<I, C, A, CreateC>) -> Self
fn from(value: RNSConvolution<I, C, A, CreateC>) -> Self
Source§impl<I, C, A, CreateC> From<RNSConvolutionZn<I, C, A, CreateC>> for RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
impl<I, C, A, CreateC> From<RNSConvolutionZn<I, C, A, CreateC>> for RNSConvolution<I, C, A, CreateC>where
I: RingStore + Clone,
I::Type: IntegerRing,
C: ConvolutionAlgorithm<ZnBase>,
A: Allocator + Clone,
CreateC: Fn(Zn) -> C,
Source§fn from(value: RNSConvolutionZn<I, C, A, CreateC>) -> Self
fn from(value: RNSConvolutionZn<I, C, A, CreateC>) -> Self
Auto Trait Implementations§
impl<I = RingValue<MPZBase>, C = NTTConvolution<ZnBase, ZnFastmulBase, CanHom<RingValue<ZnFastmulBase>, RingValue<ZnBase>>>, A = Global, CreateC = CreateNTTConvolution> !Freeze for RNSConvolution<I, C, A, CreateC>
impl<I = RingValue<MPZBase>, C = NTTConvolution<ZnBase, ZnFastmulBase, CanHom<RingValue<ZnFastmulBase>, RingValue<ZnBase>>>, A = Global, CreateC = CreateNTTConvolution> !RefUnwindSafe for RNSConvolution<I, C, A, CreateC>
impl<I, C, A, CreateC> Send for RNSConvolution<I, C, A, CreateC>
impl<I, C, A, CreateC> Sync for RNSConvolution<I, C, A, CreateC>
impl<I, C, A, CreateC> Unpin for RNSConvolution<I, C, A, CreateC>
impl<I, C, A, CreateC> UnwindSafe for RNSConvolution<I, C, A, CreateC>where
I: UnwindSafe + RefUnwindSafe,
CreateC: UnwindSafe,
A: UnwindSafe + RefUnwindSafe,
C: RefUnwindSafe + UnwindSafe,
<<I as RingStore>::Type as RingBase>::Element: RefUnwindSafe + UnwindSafe,
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