pub struct SliceSignedDecompositionNonNativeIter<T>where
T: UnsignedInteger,{ /* private fields */ }Expand description
An iterator-like object that yields the terms of the signed decomposition of a tensor of values.
§Note
On each call to SliceSignedDecompositionNonNativeIter::next_term, this structure yields a
new
DecompositionTermSlice, backed by a Vec owned by the structure. This vec is mutated at
each call of the next_term method, and as such the term must be dropped before next_term is
called again.
Such a pattern can not be implemented with iterators yet (without GATs), which is why this iterator must be explicitly called.
§Warning
This iterator yields the decomposition in reverse order. That means that the highest level will be yielded first.
Implementations§
Source§impl<T> SliceSignedDecompositionNonNativeIter<T>where
T: UnsignedInteger,
impl<T> SliceSignedDecompositionNonNativeIter<T>where
T: UnsignedInteger,
Sourcepub fn base_log(&self) -> DecompositionBaseLog
pub fn base_log(&self) -> DecompositionBaseLog
Returns the logarithm in base two of the base of this decomposition.
If the decomposition uses a base $B=2^b$, this returns $b$.
§Example
use tfhe::core_crypto::commons::math::decomposition::SignedDecomposerNonNative;
use tfhe::core_crypto::prelude::{
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount,
};
let decomposer = SignedDecomposerNonNative::<u32>::new(
DecompositionBaseLog(4),
DecompositionLevelCount(3),
CiphertextModulus::try_new((1 << 32) - (1 << 16) + 1).unwrap(),
);
let decomposable = vec![1_340_987_234_u32; 2];
let decomp = decomposer.decompose_slice(&decomposable);
assert_eq!(decomp.base_log(), DecompositionBaseLog(4));Sourcepub fn level_count(&self) -> DecompositionLevelCount
pub fn level_count(&self) -> DecompositionLevelCount
Returns the number of levels of this decomposition.
If the decomposition uses $l$ levels, this returns $l$.
§Example
use tfhe::core_crypto::commons::math::decomposition::SignedDecomposerNonNative;
use tfhe::core_crypto::prelude::{
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount,
};
let decomposer = SignedDecomposerNonNative::<u32>::new(
DecompositionBaseLog(4),
DecompositionLevelCount(3),
CiphertextModulus::try_new((1 << 32) - (1 << 16) + 1).unwrap(),
);
let decomposable = vec![1_340_987_234_u32; 2];
let decomp = decomposer.decompose_slice(&decomposable);
assert_eq!(decomp.level_count(), DecompositionLevelCount(3));Sourcepub fn next_term(&mut self) -> Option<DecompositionTermSliceNonNative<'_, T>>
pub fn next_term(&mut self) -> Option<DecompositionTermSliceNonNative<'_, T>>
Yield the next term of the decomposition, if any.
§Note
Because this function returns a borrowed tensor, owned by the iterator, the term must be
dropped before next_term is called again.
§Example
use tfhe::core_crypto::commons::math::decomposition::{
DecompositionLevel, SignedDecomposerNonNative,
};
use tfhe::core_crypto::prelude::{
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount,
};
let decomposer = SignedDecomposerNonNative::<u32>::new(
DecompositionBaseLog(4),
DecompositionLevelCount(3),
CiphertextModulus::try_new((1 << 32) - (1 << 16) + 1).unwrap(),
);
let decomposable = vec![1_340_987_234_u32; 2];
let mut decomp = decomposer.decompose_slice(&decomposable);
let term = decomp.next_term().unwrap();
assert_eq!(term.level(), DecompositionLevel(3));
assert_eq!(term.as_slice()[0], u32::MAX);Auto Trait Implementations§
impl<T> Freeze for SliceSignedDecompositionNonNativeIter<T>where
T: Freeze,
impl<T> RefUnwindSafe for SliceSignedDecompositionNonNativeIter<T>where
T: RefUnwindSafe,
impl<T> Send for SliceSignedDecompositionNonNativeIter<T>
impl<T> Sync for SliceSignedDecompositionNonNativeIter<T>
impl<T> Unpin for SliceSignedDecompositionNonNativeIter<T>where
T: Unpin,
impl<T> UnwindSafe for SliceSignedDecompositionNonNativeIter<T>where
T: 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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