Skip to content

Commit

Permalink
Defined isinf, isnan, isreal, isinteger, iseven, and isodd
Browse files Browse the repository at this point in the history
  • Loading branch information
brainandforce committed Nov 4, 2024
1 parent 3643cca commit 044e3ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CliffordNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Base: zero, one, oneunit
import Base: signbit, sign, copysign, flipsign
import Base: reverse, adjoint, conj, ~
import Base: ==, isequal, isapprox, +, -, *, /, //, muladd, abs, abs2, exp, ^
import Base: isfinite, isinf, isnan, isreal, isinteger, iseven, isodd
import Base: promote_rule, convert, similar, float, big
import Base: print, show, summary

Expand Down
15 changes: 15 additions & 0 deletions src/math/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ end
isapprox(x::AbstractCliffordNumber, y::Number; kwargs...) = isapprox(promote(x, y)...; kwargs...)
isapprox(x::Number, y::AbstractCliffordNumber; kwargs...) = isapprox(promote(y, x)...; kwargs...)

#---Other properties-------------------------------------------------------------------------------#

# Already works: Base.isfinite(x::AbstractCliffordNumber) = all(isfinite, Tuple(x))
isinf(x::AbstractCliffordNumber) = any(isinf, Tuple(x))
isnan(x::AbstractCliffordNumber) = any(isnan, Tuple(x))

isreal(x::AbstractCliffordNumber) = isreal(scalar(x)) && isscalar(x)
isreal(x::AbstractCliffordNumber{<:Any,<:Real}) = isscalar(x)

isinteger(x::AbstractCliffordNumber) = isinteger(scalar(x)) && isscalar(x)
isinteger(x::AbstractCliffordNumber{<:Any,<:Integer}) = isscalar(x)

iseven(x::AbstractCliffordNumber) = isreal(x) && iseven(real(scalar(x)))
isodd(x::AbstractCliffordNumber) = isreal(x) && isodd(real(scalar(x)))

#---Addition, negation, and subtraction------------------------------------------------------------#

+(x::T, y::T) where T<:AbstractCliffordNumber = T(map(+, Tuple(x), Tuple(y)))
Expand Down

0 comments on commit 044e3ef

Please sign in to comment.