Skip to content

Commit

Permalink
Simplified definition for == and added isequal deifnition
Browse files Browse the repository at this point in the history
  • Loading branch information
brainandforce committed Sep 11, 2024
1 parent 8e0c926 commit 683a762
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CliffordNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Base: length, size, axes, getindex, to_index
import Base: zero, one, oneunit
import Base: signbit, sign
import Base: reverse, adjoint, conj, ~
import Base: ==, isapprox, +, -, *, /, //, muladd, abs, abs2, exp, ^
import Base: ==, isequal, isapprox, +, -, *, /, //, muladd, abs, abs2, exp, ^
import Base: promote_rule, convert, similar, float, big
import Base: summary, show

Expand Down
7 changes: 3 additions & 4 deletions src/math/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#---Equality and approximate equality--------------------------------------------------------------#

function ==(x::AbstractCliffordNumber{Q}, y::AbstractCliffordNumber{Q}) where Q
return all(x[i] == y[i] for i in BitIndices(promote_type(typeof(x), typeof(y))))
end
==(x::T, y::T) where T<:AbstractCliffordNumber = Tuple(x) == Tuple(y)
isequal(x::T, y::T) where T<:AbstractCliffordNumber = isequal(Tuple(x), Tuple(y))

# Define equality with scalar values in terms of scalar operations above
# TODO: does this avoid unnecessary comparisons or construction?
==(x::AbstractCliffordNumber, y::BaseNumber) = isscalar(x) && (scalar(x) == y)
==(x::BaseNumber, y::AbstractCliffordNumber) = isscalar(y) && (x == scalar(y))

Expand Down

0 comments on commit 683a762

Please sign in to comment.