Skip to content

Commit e737375

Browse files
Merge pull request #160 from hannes-uppman/norm
Fix norm
2 parents c9857f2 + f9e64f1 commit e737375

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/math/linearalgebra/support.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function LinearAlgebra.norm(v::Array{DoubleFloat{T},N}, p::Real=2.0) where {N, T
1616
elseif p==2
1717
return vp = sqrt(sum(v .* v))
1818
else
19-
vp = sum((v).^(p))
19+
vp = sum(abs.(v).^(p))
2020
r = inv(DoubleFloat{T}(p))
2121
return vp^r
2222
end

test/linearalgebra.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ using GenericLinearAlgebra, GenericSchur
2929
@test norm(Double64[2, 1]) norm(Float64[2, 1])
3030
@test norm(Double64[2, 1], 3.0) norm(Float64[2, 1], 3.0)
3131

32+
# issue #159
33+
@test norm(Double64[-1, -1], 1) 2
34+
3235
# issue #105
3336
for T in [Double16, Double32, Double64]
3437
for p in [0, 1.0, 2.0, Inf, -Inf]

0 commit comments

Comments
 (0)