pub struct RingVector { /* private fields */ }Expand description
Vector of ring elements over Z_m.
Implementations§
Source§impl RingVector
impl RingVector
Sourcepub fn new(elements: Vec<RingElement>) -> Self
pub fn new(elements: Vec<RingElement>) -> Self
Create a new vector from a slice of ring elements.
§Panics
Panics if the vector is empty or elements have different moduli.
Sourcepub fn try_new(elements: Vec<RingElement>) -> Result<Self, RingError>
pub fn try_new(elements: Vec<RingElement>) -> Result<Self, RingError>
Try to create a new vector from ring elements.
§Errors
Returns RingError::DimensionMismatch if the vector is empty and
RingError::ModulusMismatch if the elements do not share the same modulus.
Sourcepub fn from_values(values: &[u64], modulus: u64) -> Self
pub fn from_values(values: &[u64], modulus: u64) -> Self
Create a vector from raw values.
Sourcepub fn get(&self, index: usize) -> RingElement
pub fn get(&self, index: usize) -> RingElement
Sourcepub fn set(&mut self, index: usize, value: RingElement)
pub fn set(&mut self, index: usize, value: RingElement)
Sourcepub fn elements(&self) -> &[RingElement]
pub fn elements(&self) -> &[RingElement]
Return the underlying elements as a slice.
Sourcepub fn dot(&self, other: &Self) -> RingElement
pub fn dot(&self, other: &Self) -> RingElement
Compute dot product with another vector.
§Panics
Panics if vectors have different lengths or different moduli.
Sourcepub fn try_dot(&self, other: &Self) -> Result<RingElement, RingError>
pub fn try_dot(&self, other: &Self) -> Result<RingElement, RingError>
Compute a checked dot product with another vector.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn scale(&self, scalar: RingElement) -> Self
pub fn scale(&self, scalar: RingElement) -> Self
Sourcepub fn try_add(&self, other: &Self) -> Result<Self, RingError>
pub fn try_add(&self, other: &Self) -> Result<Self, RingError>
Compute a checked element-wise sum.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn try_sub(&self, other: &Self) -> Result<Self, RingError>
pub fn try_sub(&self, other: &Self) -> Result<Self, RingError>
Compute a checked element-wise difference.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn iter(&self) -> impl Iterator<Item = &RingElement>
pub fn iter(&self) -> impl Iterator<Item = &RingElement>
Get iterator over elements.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut RingElement>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut RingElement>
Get mutable iterator over elements.
Trait Implementations§
Source§impl<'b> Add<&'b RingVector> for &RingVector
impl<'b> Add<&'b RingVector> for &RingVector
Source§type Output = RingVector
type Output = RingVector
+ operator.Source§fn add(self, other: &'b RingVector) -> RingVector
fn add(self, other: &'b RingVector) -> RingVector
+ operation. Read moreSource§impl Add for RingVector
impl Add for RingVector
Source§impl Clone for RingVector
impl Clone for RingVector
Source§fn clone(&self) -> RingVector
fn clone(&self) -> RingVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RingVector
impl Debug for RingVector
Source§impl<'de> Deserialize<'de> for RingVector
impl<'de> Deserialize<'de> for RingVector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Index<usize> for RingVector
impl Index<usize> for RingVector
Source§impl IndexMut<usize> for RingVector
impl IndexMut<usize> for RingVector
Source§impl Neg for RingVector
impl Neg for RingVector
Source§impl PartialEq for RingVector
impl PartialEq for RingVector
Source§impl Serialize for RingVector
impl Serialize for RingVector
Source§impl<'b> Sub<&'b RingVector> for &RingVector
impl<'b> Sub<&'b RingVector> for &RingVector
Source§type Output = RingVector
type Output = RingVector
- operator.Source§fn sub(self, other: &'b RingVector) -> RingVector
fn sub(self, other: &'b RingVector) -> RingVector
- operation. Read more