Skip to main content

MulByScalar

Trait MulByScalar 

Source
pub trait MulByScalar<Rhs, Out = Self>: Sized {
    // Required method
    fn mul_by_scalar<const CHECK: bool>(self, rhs: &Rhs) -> Option<Out>;
}
Expand description

Multiplication of an element by a scalar of a (possibly) different type. This multiplication can widen the result.

Note that this is for static semirings only, dynamic fields don’t go through this route.

Required Methods§

Source

fn mul_by_scalar<const CHECK: bool>(self, rhs: &Rhs) -> Option<Out>

Multiplies self by a scalar from the right (usually - a coefficient to obtain a linear combination). Returns None if the multiplication would overflow.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MulByScalar<i8> for i8

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i8) -> Option<i8>

Source§

impl MulByScalar<i16> for i16

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i16) -> Option<i16>

Source§

impl MulByScalar<i32> for i32

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i32) -> Option<i32>

Source§

impl MulByScalar<i64> for i64

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i64) -> Option<i64>

Source§

impl MulByScalar<i64> for i128

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i64) -> Option<i128>

Source§

impl MulByScalar<i64, i128> for i32

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i64) -> Option<i128>

Source§

impl MulByScalar<i64, i128> for i64

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i64) -> Option<i128>

Source§

impl MulByScalar<i128> for i128

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i128) -> Option<i128>

Source§

impl<Mod: ConstMontyParams<LIMBS>, const LIMBS: usize> MulByScalar<ConstMontyField<Mod, LIMBS>> for ConstMontyField<Mod, LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>( self, rhs: &ConstMontyField<Mod, LIMBS>, ) -> Option<ConstMontyField<Mod, LIMBS>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<i8, Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i8) -> Option<Int<LIMBS2>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<i16, Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i16) -> Option<Int<LIMBS2>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<i32, Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i32) -> Option<Int<LIMBS2>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<i64, Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i64) -> Option<Int<LIMBS2>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<i128, Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>(self, rhs: &i128) -> Option<Int<LIMBS2>>

Source§

impl<const LIMBS: usize, const LIMBS2: usize> MulByScalar<Int<LIMBS2>> for Int<LIMBS>

Source§

fn mul_by_scalar<const CHECK: bool>( self, rhs: &Int<LIMBS2>, ) -> Option<Int<LIMBS>>

Implementors§

Source§

impl<T> MulByScalar<Boolean> for T
where T: Clone + ConstZero + From<Boolean>,

Multiplication by a [Boolean] scalar: selects lhs or zero.