From b3a30cb26b97a1df3952ed92ebff14937f55abbf Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:50:28 +0100 Subject: [PATCH] Update positive.jl --- src/utils/positive.jl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/utils/positive.jl b/src/utils/positive.jl index ee047e3..f374900 100644 --- a/src/utils/positive.jl +++ b/src/utils/positive.jl @@ -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 """ @@ -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 """