Skip to content

Commit 8dddfd5

Browse files
committed
Tests for complex norms
1 parent 956b91a commit 8dddfd5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/math/linearalgebra/support.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function norm(v::Array{Complex{DoubleFloat{T}},N}, p::Real=2.0) where {N, T<:IEE
2424
if isinf(p)
2525
return signbit(p) ? minimum(abs.(real.(v))) : maximum(abs.(real.(v)))
2626
elseif p==2
27-
return vp = sqrt(sum(conj.(v) .* v))
27+
return vp = sqrt(real(sum(conj.(v) .* v)))
2828
else
2929
vp = sum(abs.(v).^(p))
3030
r = inv(DoubleFloat{T}(p))

test/linearalgebra.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
Complex{Double64}(0.0,-1.0) Complex{Double64}(1.0,0.0)]
1212
@test ishermitian(t)
1313

14-
@test norm(Complex{Double64}[2, 2im]) norm(Float64[2, 2im])
15-
@test norm(Complex{Double64}[2, 2im], 3.0) norm(Float64[2, 2im], 3.0)
14+
@test norm(Complex{Double64}[2, 2im]) norm(ComplexF64[2, 2im])
15+
@test norm(Complex{Double64}[2, 2im]) isa Double64
16+
17+
@test norm(Complex{Double64}[2, 2im], 3.0) norm(ComplexF64[2, 2im], 3.0)
18+
@test norm(Complex{Double64}[2, 2im], 3.0) isa Double64
19+
1620
@test norm(Double64[2, 1]) norm(Float64[2, 1])
1721
@test norm(Double64[2, 1], 3.0) norm(Float64[2, 1], 3.0)
1822
end

0 commit comments

Comments
 (0)