From af0819492eda78e20d3edcd52793bffd5e8b7a05 Mon Sep 17 00:00:00 2001 From: Brandon Flores Date: Fri, 20 Sep 2024 16:37:38 -0500 Subject: [PATCH] Added comments for `isscalar` behavior and testing --- src/math/scalar.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/math/scalar.jl b/src/math/scalar.jl index 35acd8a..edfc33f 100644 --- a/src/math/scalar.jl +++ b/src/math/scalar.jl @@ -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