pub enum Coefficient<R: ?Sized + RingBase> {
Zero,
One,
NegOne,
Integer(i32),
Other(R::Element),
}Expand description
A coefficient used in a PlaintextCircuit.
Generally speaking, this always represents an element of R
(which can be retrieved via Coefficient::to_ring_el()), but
special cases are stored separately for a more efficient evaluation.
Variants§
Implementations§
Source§impl<R: ?Sized + RingBase> Coefficient<R>
impl<R: ?Sized + RingBase> Coefficient<R>
pub fn clone<S: RingStore<Type = R>>(&self, ring: S) -> Self
pub fn eq<S: RingStore<Type = R> + Copy>(&self, other: &Self, ring: S) -> bool
Sourcepub fn add_to<S: RingStore<Type = R> + Copy>(&self, x: El<S>, ring: S) -> El<S>
pub fn add_to<S: RingStore<Type = R> + Copy>(&self, x: El<S>, ring: S) -> El<S>
Computes self + x, but avoids a full ring addition if self is zero.
Sourcepub fn mul_to<S: RingStore<Type = R> + Copy>(&self, x: El<S>, ring: S) -> El<S>
pub fn mul_to<S: RingStore<Type = R> + Copy>(&self, x: El<S>, ring: S) -> El<S>
Computes self * x, but avoids a full ring multiplication if self
is stored as an integer.
pub fn is_zero(&self) -> bool
pub fn to_ring_el<S: RingStore<Type = R>>(self, ring: S) -> El<S>
pub fn negate<S: RingStore<Type = R>>(self, ring: S) -> Self
pub fn add<S: RingStore<Type = R> + Copy>(self, other: Self, ring: S) -> Self
pub fn mul<S: RingStore<Type = R> + Copy>(self, other: Self, ring: S) -> Self
Sourcepub fn change_ring<S, F>(self, f: F) -> Coefficient<S>
pub fn change_ring<S, F>(self, f: F) -> Coefficient<S>
Preserves integer coefficients, and maps ring elements as specified by the given function.
Trait Implementations§
Source§impl<R> Clone for Coefficient<R>
impl<R> Clone for Coefficient<R>
impl<R> Copy for Coefficient<R>
Auto Trait Implementations§
impl<R> Freeze for Coefficient<R>
impl<R> RefUnwindSafe for Coefficient<R>
impl<R> Send for Coefficient<R>
impl<R> Sync for Coefficient<R>
impl<R> Unpin for Coefficient<R>
impl<R> UnwindSafe for Coefficient<R>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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