Skip to content

Commit

Permalink
Added comments for isscalar behavior and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brainandforce committed Sep 20, 2024
1 parent ddb115b commit af08194
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/math/scalar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
Determines whether the Clifford number `x` is a scalar, meaning that all of its blades of nonzero
grade are zero.
"""
# TODO: how to test this fallback method which is not used by any internal types?
function isscalar(x::AbstractCliffordNumber)
inds = Iterators.filter(!isequal(scalar_index(x)), BitIndices(x))
return all(iszero, x[i] for i in inds)
end

# The first index of these types is the scalar index
isscalar(x::Union{CliffordNumber,EvenCliffordNumber}) = all(iszero, Tuple(x)[2:end])
# These types cannot be scalars unless they are zero
isscalar(x::OddCliffordNumber) = iszero(x)
isscalar(x::KVector) = iszero(x)
# These types are definitely scalars
isscalar(::KVector{0}) = true
isscalar(::BaseNumber) = true

Expand Down

0 comments on commit af08194

Please sign in to comment.