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 vectors by value #119

Merged
merged 2 commits into from
Oct 27, 2017
Merged

Conversation

milibopp
Copy link
Contributor

This is the first tiny step towards #118.

alga's ClosedAdd trait requires addition by value. These implementations merely delegate to the by-reference implementation. I imagine that there is some space for optimization here later on, if you take ownership of the operands.

The same considerations apply for the other operators, too. I'd be happy to apply the procedure to all of them (could be done in this PR), but I would like to get feedback on this approach first.

Copy link
Collaborator

@vbarrielle vbarrielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one nitpick (but it's actually my fault): CsVec is in fact generic over the index type, so IS1 should have the bound IS1: I where I: SpIndex.

Looks like I had forgotten to propagate this change in the addition trait, which is probably why it's also present in your PR.

If you wish to fix that before I merge the PR, go ahead, otherwise I will merge it and fix it afterwards.

Thanks!

impl<N, IS1, DS1, IS2, DS2> Add<CsVecBase<IS2, DS2>>
for CsVecBase<IS1, DS1>
where N: Copy + Num,
IS1: Deref<Target=[usize]>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS1 could be deref on a generic Index type, as in https://github.com/vbarrielle/sprs/blob/master/src/sparse/vec.rs#L814-L823

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix it with the PR, while I am at it ;)

@vbarrielle
Copy link
Collaborator

That's perfect, thanks a lot!

@vbarrielle vbarrielle merged commit a5e393f into sparsemat:master Oct 27, 2017
@milibopp milibopp deleted the add-vec-by-value branch October 27, 2017 15:10
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.

2 participants