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 fkeep! and children for sparse vectors #15585

Merged
merged 2 commits into from
Apr 13, 2016

Conversation

KristofferC
Copy link
Member

Since these exist for sparse matrices it makes sense that they do for sparse vectors.

I used functors to keep the same style of code for matrices and vectors. If functors gives no performance benefit they can be swapped out for both matrices and vectors in a separate PR.

x
end

immutable DroptolFuncVec <: Base.Func{3} end
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK passing anonymous functions is fast now, so you don't need to use functors, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Please see PR description.

@KristofferC KristofferC force-pushed the kc/fkeep_sparse_vector branch 2 times, most recently from 81b55e9 to 0ffe3cc Compare March 23, 2016 08:57
@KristofferC
Copy link
Member Author

Updated to address comments. I looked and anonymous functions seems to work as well as functors but I rather keep the PRs small.

@@ -1680,7 +1680,7 @@ function sort{Tv,Ti}(x::SparseVector{Tv,Ti}; kws...)
SparseVector(n,newnzind,newnzvals)
end

function fkeep!{Tv,Ti}(x::SparseVector{Tv,Ti}, f, other, trim::Bool = true)
function fkeep!(x::SparseVector{Tv,Ti}, f, other, trim::Bool = true)
Copy link
Member

Choose a reason for hiding this comment

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

I think the extraneous {Tv,Ti} is the cause of the build failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, will fix. Thanks

@KristofferC KristofferC force-pushed the kc/fkeep_sparse_vector branch 2 times, most recently from cfcd3b6 to 83326ca Compare March 23, 2016 10:17
is `true`, this method trims `A.rowval` and `A.nzval` to length `nnz(A)` after dropping
elements.
through `A`, requiring `O(A.n, nnz(A))`-time for matrices and `O(nnz(A))`-time for vectors
and no space beyond that passed in. If `trim` is `true`, this method trims `A.rowval/A.nzind` and
Copy link
Contributor

Choose a reason for hiding this comment

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

not a division

Copy link
Member Author

Choose a reason for hiding this comment

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

trims A.rowval or A.nzind

like that?

@KristofferC KristofferC force-pushed the kc/fkeep_sparse_vector branch from 83326ca to 3a476f7 Compare March 29, 2016 09:06
@KristofferC
Copy link
Member Author

Updated to address @tkelman documentation comment.

@KristofferC
Copy link
Member Author

Test error seems irrelevant (SubArrays) on one worker.

@KristofferC
Copy link
Member Author

This is good to go from my P.O.V

@ViralBShah ViralBShah added the sparse Sparse arrays label Apr 4, 2016
xdrop = Base.droptol!(copy(x), 1.5)
@test exact_equal(xdrop, SparseVector(7, [1, 2, 5, 6, 7], [3., 2., -2., -3., 3.]))
Base.droptol!(xdrop, 2.5)
@test exact_equal(xdrop, SparseVector(7, [1, 6, 7], [3., -3., 3.]))
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a test of droptol! where the tolerance is exactly equal to one of the nonzero values? then I think this is done

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@KristofferC KristofferC force-pushed the kc/fkeep_sparse_vector branch from 3a476f7 to 5a30b99 Compare April 13, 2016 07:42
@KristofferC KristofferC force-pushed the kc/fkeep_sparse_vector branch from 5a30b99 to 2ad39b4 Compare April 13, 2016 08:20
@KristofferC
Copy link
Member Author

This will slightly clash with #15804 since it adds a few functor methods. Maybe they can be fixed in the same way in that PR.

@tkelman tkelman merged commit 1b4618e into JuliaLang:master Apr 13, 2016
@tkelman
Copy link
Contributor

tkelman commented Apr 13, 2016

hopefully @martinholters won't mind getting rid of a couple more there?

@KristofferC KristofferC deleted the kc/fkeep_sparse_vector branch April 13, 2016 17:48
@martinholters
Copy link
Member

I won't.

@martinholters martinholters mentioned this pull request Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants