Struct snarkvm_r1cs::LinearCombination[][src]

pub struct LinearCombination<F: Field>(pub Vec<(Variable, F)>);
Expand description

This represents a linear combination of some variables, with coefficients in the field F. The (coeff, var) pairs in a LinearCombination are kept sorted according to the index of the variable in its constraint system.

Implementations

impl<F: Field> LinearCombination<F>[src]

pub fn zero() -> LinearCombination<F>[src]

Outputs an empty linear combination.

pub fn replace_in_place(&mut self, other: Self)[src]

Replaces the contents of self with those of other.

pub fn negate_in_place(&mut self)[src]

Negate the coefficients of all variables in self.

pub fn double_in_place(&mut self)[src]

Double the coefficients of all variables in self.

pub fn get_var_loc(&self, search_var: &Variable) -> Result<usize, usize>[src]

Get the location of a variable in self.

Trait Implementations

impl<F: Field> Add<&'_ LinearCombination<F>> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(self, other: &LinearCombination<F>) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<'a, F: Field> Add<&'a LinearCombination<F>> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(self, other: &'a LinearCombination<F>) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<F: Field> Add<(F, &'_ LinearCombination<F>)> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(
    self,
    (mul_coeff, other): (F, &LinearCombination<F>)
) -> LinearCombination<F>
[src]

Performs the + operation. Read more

impl<'a, F: Field> Add<(F, &'a LinearCombination<F>)> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(
    self,
    (mul_coeff, other): (F, &'a LinearCombination<F>)
) -> LinearCombination<F>
[src]

Performs the + operation. Read more

impl<F: Field> Add<(F, LinearCombination<F>)> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(
    self,
    (mul_coeff, other): (F, LinearCombination<F>)
) -> LinearCombination<F>
[src]

Performs the + operation. Read more

impl<F: Field> Add<(F, LinearCombination<F>)> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, (mul_coeff, other): (F, Self)) -> Self[src]

Performs the + operation. Read more

impl<F: Field> Add<(F, Variable)> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, coeff_var: (F, Variable)) -> Self[src]

Performs the + operation. Read more

impl<F: Field> Add<LinearCombination<F>> for ConstraintVariable<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(self, other_lc: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<F: Field> Add<LinearCombination<F>> for &ConstraintVariable<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(self, other_lc: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<F: Field> Add<LinearCombination<F>> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the + operator.

fn add(self, other: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<F: Field> Add<LinearCombination<F>> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Self) -> Self[src]

Performs the + operation. Read more

impl<F: Field> Add<Variable> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Variable) -> LinearCombination<F>[src]

Performs the + operation. Read more

impl<F: Field> AddAssign<(F, Variable)> for LinearCombination<F>[src]

fn add_assign(&mut self, (coeff, var): (F, Variable))[src]

Performs the += operation. Read more

impl<F: Field> AsRef<[(Variable, F)]> for LinearCombination<F>[src]

fn as_ref(&self) -> &[(Variable, F)][src]

Performs the conversion.

impl<F: Clone + Field> Clone for LinearCombination<F>[src]

fn clone(&self) -> LinearCombination<F>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<F: Debug + Field> Debug for LinearCombination<F>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<F: Field> From<(F, Variable)> for LinearCombination<F>[src]

fn from((coeff, var): (F, Variable)) -> Self[src]

Performs the conversion.

impl<F: Field> From<LinearCombination<F>> for ConstraintVariable<F>[src]

fn from(lc: LinearCombination<F>) -> Self[src]

Performs the conversion.

impl<F: Field> From<Variable> for LinearCombination<F>[src]

fn from(var: Variable) -> Self[src]

Performs the conversion.

impl<F: Hash + Field> Hash for LinearCombination<F>[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<F: Field> Mul<F> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, scalar: F) -> Self[src]

Performs the * operation. Read more

impl<F: Field> MulAssign<F> for LinearCombination<F>[src]

fn mul_assign(&mut self, scalar: F)[src]

Performs the *= operation. Read more

impl<F: Field> Neg for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the - operator.

fn neg(self) -> Self[src]

Performs the unary - operation. Read more

impl<F: PartialEq + Field> PartialEq<LinearCombination<F>> for LinearCombination<F>[src]

fn eq(&self, other: &LinearCombination<F>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &LinearCombination<F>) -> bool[src]

This method tests for !=.

impl<F: Field> Sub<&'_ LinearCombination<F>> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other: &LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<'a, F: Field> Sub<&'a LinearCombination<F>> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other: &'a LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<(F, &'_ LinearCombination<F>)> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, (coeff, other): (F, &LinearCombination<F>)) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<'a, F: Field> Sub<(F, &'a LinearCombination<F>)> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(
    self,
    (coeff, other): (F, &'a LinearCombination<F>)
) -> LinearCombination<F>
[src]

Performs the - operation. Read more

impl<F: Field> Sub<(F, LinearCombination<F>)> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, (coeff, other): (F, LinearCombination<F>)) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<'a, F: Field> Sub<(F, LinearCombination<F>)> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, (coeff, other): (F, LinearCombination<F>)) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<(F, Variable)> for LinearCombination<F>[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, (coeff, var): (F, Variable)) -> Self[src]

Performs the - operation. Read more

impl<F: Field> Sub<LinearCombination<F>> for ConstraintVariable<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other_lc: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<LinearCombination<F>> for &ConstraintVariable<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other_lc: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<LinearCombination<F>> for &LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<LinearCombination<F>> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other: LinearCombination<F>) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Field> Sub<Variable> for LinearCombination<F>[src]

type Output = LinearCombination<F>

The resulting type after applying the - operator.

fn sub(self, other: Variable) -> LinearCombination<F>[src]

Performs the - operation. Read more

impl<F: Eq + Field> Eq for LinearCombination<F>[src]

impl<F: Field> StructuralEq for LinearCombination<F>[src]

impl<F: Field> StructuralPartialEq for LinearCombination<F>[src]

Auto Trait Implementations

impl<F> RefUnwindSafe for LinearCombination<F> where
    F: RefUnwindSafe

impl<F> Send for LinearCombination<F>

impl<F> Sync for LinearCombination<F>

impl<F> Unpin for LinearCombination<F> where
    F: Unpin

impl<F> UnwindSafe for LinearCombination<F> where
    F: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V