@@ -111,8 +111,11 @@ function LinearAlgebra.normalize(V::DeviceSparseVector, p::Real = 2)
111111end
112112
113113function LinearAlgebra. dot(x:: DeviceSparseVector , y:: DenseVector )
114- length(x) == length(y) ||
115- throw(DimensionMismatch(" Vector x has a length $(length(x)) but y has a length $n " ))
114+ length(x) == length(y) || throw(
115+ DimensionMismatch(
116+ " Vector x has a length $(length(x)) but y has a length $(length(y)) " ,
117+ ),
118+ )
116119
117120 T = Base. promote_eltype(x, y)
118121
@@ -161,19 +164,6 @@ function _prep_sparsevec_copy_dest!(A::DeviceSparseVector, lB, nnzB)
161164 resize!(nonzeros(A), nnzB)
162165 resize!(nonzeroinds(A), nnzB)
163166 else
164- nnzA = nnz(A)
165-
166- lastmodindA = searchsortedlast(nonzeroinds(A), lB)
167- if lastmodindA >= nnzB
168- # A will have fewer non-zero elements; unmodified elements are kept at the end.
169- deleteat!(nonzeroinds(A), (nnzB+ 1 ): lastmodindA)
170- deleteat!(nonzeros(A), (nnzB+ 1 ): lastmodindA)
171- else
172- # A will have more non-zero elements; unmodified elements are kept at the end.
173- resize!(nonzeroinds(A), nnzB + nnzA - lastmodindA)
174- resize!(nonzeros(A), nnzB + nnzA - lastmodindA)
175- copyto!(nonzeroinds(A), nnzB+ 1 , nonzeroinds(A), lastmodindA+ 1 , nnzA- lastmodindA)
176- copyto!(nonzeros(A), nnzB+ 1 , nonzeros(A), lastmodindA+ 1 , nnzA- lastmodindA)
177- end
167+ throw(ArgumentError(" Cannot copy to a sparse vector of different length" ))
178168 end
179169end
0 commit comments