Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for adding/subtracting vectors #1205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

cjpatton
Copy link
Collaborator

@cjpatton cjpatton commented Jan 18, 2025

Closes #301: see #301 (comment).

Add a method add_assign_vector that replaces the following zip pattern:

for (x, y) in a.iter_mut().zip(y) {
    *x += *y;
}

The method also panics if b is shorter than a.

Replace the zip pattern with this method wherever we add up vectors. This helps us ensure that we're not accidentally adding a vector that's shorter than the other.

Likewise for subtracting vectors.

@cjpatton cjpatton marked this pull request as ready for review January 18, 2025 00:30
@cjpatton cjpatton requested a review from a team as a code owner January 18, 2025 00:30
Add a method `add_assign_vector` that replaces the following zip
pattern:

```
for (x, y) in a.iter_mut().zip(y) {
    *x += *y;
}
```

The method also panics if `b` is shorter than `a`.

Replace the zip pattern with this method wherever we add up vectors.
This helps us ensure that we're not accidentally adding a vector that's
shorter than the other.

Likewise for subtracting vectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement std::ops::Add for vectors of field elements
1 participant