Skip to content

Commit

Permalink
Update positive.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Nov 10, 2024
1 parent 796b6ad commit b3a30cb
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/utils/positive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ function pos(vector::AbstractArray)
return r
end

function pos(number::T) where {T <: Number}
if isnan(number) || number < zero(T)
return zero(T)
else
return number
end
@inline function pos(x::T) where {T <: Number}
return isnan(x) || x < zero(T) ? zero(T) : x
end

"""
Expand Down Expand Up @@ -81,12 +77,8 @@ function neg(vector::AbstractArray)
return r
end

function neg(number::T) where {T <: Number}
if isnan(number) || number > zero(T)
return zero(T)
else
return number
end
@inline function neg(x::T) where {T <: Number}
return isnan(x) || x > zero(T) ? zero(T) : x
end

"""
Expand Down

0 comments on commit b3a30cb

Please sign in to comment.