-
Notifications
You must be signed in to change notification settings - Fork 55
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
operations on subtypes of AbstractSparseVector #219
Comments
maybe the function could convert back to the type of on a side note the speed is really bad at the moment. 50~100 times worst. julia> a = sprandn(1000, 0.05);
julia> v = Polymake.SparseVector{Float64}(Vector(a));
julia> @btime 2 * $a;@btime 2 .* $a;@btime 2 * $v;@btime 2 .* $v;
62.529 ns (2 allocations: 896 bytes)
112.026 ns (4 allocations: 928 bytes)
11.710 μs (1 allocation: 16 bytes)
11.581 μs (1 allocation: 16 bytes) |
That will probably be difficult as
I think limiting these operations would be reasonable yes.
This is expected and not really important, the type is almost exclusively used for passing data to back and forth and not for computations in julia. |
seems like i've linked the wrong issue, meant to say #201 |
i think a |
Perhaps we should redo parts of the "offending" #175? Including the abstract type in the union has side effects beyond what was to be fixed in that PR, but I don't think we need to include it. |
I believe the issue is already resolved. We currently have const SparseVectorUnion{Tv,Ti} = Union{AbstractCompressedVector{Tv,Ti}, SparseColumnView{Tv,Ti}, SparseVectorView{Tv,Ti}} where abstract type AbstractCompressedVector{Tv,Ti} <: AbstractSparseVector{Tv,Ti} end So, if your custom sparse vector type subtypes |
Thanks for the update! We only subtype It is indeed not yet in julia nightly, but I will try it again after the next stdlib update and re-open the issue if necessary. |
We are using a custom sparse vector type in Polymake.jl (backed by a C++ library) that is a subtype of AbstractSparseVector. With the recent merge of #175 and the stdlib bump in julia nightly our tests started to fail because scalar*vector multiplication now converts the vector to a julia
SparseArrays.SparseVector
instead of using the genericAbstractArray
operation as a fallback:Current nightly:
With an older julia nightly we had:
The relevant operations are defined here:
SparseArrays.jl/src/sparsevector.jl
Lines 1540 to 1542 in c4b46a9
and the
SparseVectorUnion
was extended to the abstract type here.For the negate operation this does not happen and
still works as expected in the current nightly.
I am not really sure if this is a bug or by design and we need to implement all those operations explicitly?
The text was updated successfully, but these errors were encountered: