Skip to content

Commit

Permalink
show what's wrong on AV
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahao committed Oct 21, 2015
1 parent 244a1ab commit 9c02781
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ function normalize!(v::AbstractVector, p::Real=2)
__normalize!(v, nrm)
end

@inline function __normalize!{T}(v::AbstractVector{T}, nrm::T)
@inline function __normalize!{T<:AbstractFloat}(v::AbstractVector{T}, nrm::T)
#The largest positive floating point number whose inverse is less than
#infinity
const δ = inv(prevfloat(typemax(float(T))))
const δ = inv(prevfloat(typemax(T)))

if nrm δ #Safe to multiply with inverse
invnrm = inv(nrm)
Expand Down
10 changes: 9 additions & 1 deletion test/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ end

let
v = [3.0, 4.0]
@show norm(v)
@test norm(v) === 5.0
w = normalize(v)
@show w
@test w == [0.6, 0.8]
@show norm(w)
@test norm(w) === 1.0
@show normalize!(v)
@test normalize!(v) == w
end

Expand All @@ -165,9 +169,13 @@ let
δ = inv(prevfloat(typemax(float(nrm))))
v = [δ, -δ]

@show norm(v)
@test norm(v) === 7.866824069956793e-309
w = normalize(v)
@test norm(w) === 1.0
@show w
@test w [1/√2, -1/√2]
@show norm(w)
@test norm(w) === 1.0
@show normalize!(v)
@test normalize!(v) == w
end

0 comments on commit 9c02781

Please sign in to comment.