Skip to content

Commit ff725e0

Browse files
authored
type-stability in flipsign (#323)
1 parent e4bfbeb commit ff725e0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/LinearAlgebra/helper.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ normalize!(n,w::Union{Vector{T},Ptr{T}}) where {T<:Union{ComplexF64,ComplexF32}}
2323

2424

2525
flipsign(x,y) = Base.flipsign(x,y)
26-
flipsign(x,y::Complex) = y==0 ? x : x*sign(y)
26+
flipsign(x,y::Complex) = x * (z = sign(y); iszero(y) ? one(z) : z)
2727

2828
# Used for spaces not defined yet
2929
struct UnsetNumber <: Number end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ end
8282
@test all(==(D), v)
8383
end
8484

85+
@test @inferred(ApproxFunBase.flipsign(2, 0im)) == 2
86+
8587
# TODO: Tensorizer tests
8688
end
8789

0 commit comments

Comments
 (0)