Skip to content

Commit

Permalink
lmul! ambiguity fix
Browse files Browse the repository at this point in the history
  • Loading branch information
denizyuret committed Oct 13, 2019
1 parent aad2f86 commit cefbf54
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ end

# These are used in Knet/src/update.jl:
import LinearAlgebra: axpy!, norm, lmul!
axpy!(a, x::Sparse, y::AbstractArray) = addto!(y, a*x)
lmul!(a, x::Sparse{T,N}) where {T,N} = Sparse{T,N}(x.container, [ a*v for v in x.values ], x.indices)
axpy!(a::Number, x::Sparse, y::AbstractArray) = addto!(y, a*x)
lmul!(a::Number, x::Sparse{T,N}) where {T,N} = Sparse{T,N}(x.container, [ a*v for v in x.values ], x.indices)

# This does not give the correct result when there are repeated indices, but should be good enough for gclip
norm(x::Sparse) = sqrt(sum(abs2, norm(v) for v in x.values))
Expand Down

0 comments on commit cefbf54

Please sign in to comment.