Skip to content

Commit

Permalink
Fix projecto conversion, apply to complex numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahpslewis committed Aug 9, 2023
1 parent ce1a02a commit 14e6b75
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/projection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,23 @@ ProjectTo(::Number) = ProjectTo{Number}()

function ProjectTo(x::Integer)
@static if int2float_type == "Float16"
return ProjectTo{Float16}()
return ProjectTo(Float16(x))
elseif int2float_type == "Float32"
return ProjectTo{Float32}()
return ProjectTo(Float32(x))
else # Float64
return ProjectTo{Float64}()
return ProjectTo(Float64(x))
end
end

ProjectTo(x::Complex{<:Integer}) = ProjectTo(float(x))
function ProjectTo(x::Complex{<:Integer})
@static if int2float_type == "Float16"
return ProjectTo(Float16(x))
elseif int2float_type == "Float32"
return ProjectTo(Float32(x))
else # Float64
return ProjectTo(Float64(x))
end
end

# Preserve low-precision floats as accidental promotion is a common performance bug
for T in (Float16, Float32, Float64, ComplexF16, ComplexF32, ComplexF64)
Expand Down

0 comments on commit 14e6b75

Please sign in to comment.