pub trait ArithmeticBundleGadgets: FancyArithmetic {
// Provided methods
fn add_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item> { ... }
fn sub_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item> { ... }
fn mul_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>> { ... }
fn mixed_radix_addition(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>> { ... }
fn mixed_radix_addition_msb_only(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Self::Item> { ... }
fn mask(
&mut self,
b: &Self::Item,
x: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>> { ... }
fn eq_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item> { ... }
}Expand description
Arithmetic operations on wire bundles, extending the capability of FancyArithmetic operating
on individual wires.
Provided Methods§
Sourcefn add_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item>
fn add_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>
Add two wire bundles pairwise, zipping addition.
In CRT this is plain addition. In binary this is xor.
§Panics
Panics if x and y are not of the same length.
Sourcefn sub_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item>
fn sub_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>
Subtract two wire bundles, residue by residue.
In CRT this is plain subtraction. In binary this is xor.
§Panics
Panics if x and y are not of the same length.
Sourcefn mul_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn mul_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Multiply each wire in x with each wire in y, pairwise.
In CRT this is plain multiplication. In binary this is and.
Sourcefn mixed_radix_addition(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn mixed_radix_addition( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Sourcefn mixed_radix_addition_msb_only(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn mixed_radix_addition_msb_only( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Mixed radix addition only returning the MSB.
§Panics
Panics if xs is empty, or the moduli in xs are not all equal.