Skip to content

Commit 7a9e575

Browse files
authored
chore(docs): update documentation for Linear Combinations section (#51)
1 parent 5a5df66 commit 7a9e575

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/linear_relation/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ impl<T, F: Field> From<Sum<T>> for Sum<Weighted<T, F>> {
142142
/// Represents a sparse linear combination of scalars and group elements.
143143
///
144144
/// For example, it can represent an equation like:
145-
/// `s_1 * P_1 + s_2 * P_2 + ... + s_n * P_n`
145+
/// `w_1 * (s_1 * P_1) + w_2 * (s_2 * P_2) + ... + w_n * (s_n * P_n)`
146146
///
147-
/// where `s_i` are scalars (referenced by `scalar_vars`) and `P_i` are group elements (referenced by `element_vars`).
147+
/// where:
148+
/// - `(s_i * P_i)` are the terms, with `s_i` scalars (referenced by `scalar_vars`) and `P_i` group elements (referenced by `element_vars`).
149+
/// - `w_i` are the constant weight scalars
148150
///
149151
/// The indices refer to external lists managed by the containing LinearMap.
150152
pub type LinearCombination<G> = Sum<Weighted<Term<G>, <G as Group>::Scalar>>;
@@ -368,22 +370,21 @@ where
368370
}
369371

370372
/// Adds a new equation to the statement of the form:
371-
/// `lhs = Σ (scalar_i * point_i)`.
373+
/// `lhs = Σ weight_i * (scalar_i * point_i)`.
372374
///
373375
/// # Parameters
374376
/// - `lhs`: The image group element variable (left-hand side of the equation).
375-
/// - `rhs`: A slice of `(ScalarVar, GroupVar)` pairs representing the linear combination on the right-hand side.
377+
/// - `rhs`: An instance of [`LinearCombination`] representing the linear combination on the right-hand side.
376378
pub fn append_equation(&mut self, lhs: GroupVar<G>, rhs: impl Into<LinearCombination<G>>) {
377379
self.linear_map.append(rhs.into());
378380
self.image.push(lhs);
379381
}
380382

381383
/// Adds a new equation to the statement of the form:
382-
/// `lhs = Σ (scalar_i * point_i)`.
384+
/// `lhs = Σ weight_i * (scalar_i * point_i)` without allocating `lhs`.
383385
///
384386
/// # Parameters
385-
/// - `lhs`: The image group element variable (left-hand side of the equation).
386-
/// - `rhs`: A slice of `(ScalarVar, GroupVar)` pairs representing the linear combination on the right-hand side.
387+
/// - `rhs`: An instance of [`LinearCombination`] representing the linear combination on the right-hand side.
387388
pub fn allocate_eq(&mut self, rhs: impl Into<LinearCombination<G>>) -> GroupVar<G> {
388389
let var = self.allocate_element();
389390
self.append_equation(var, rhs);

0 commit comments

Comments
 (0)