diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ea6b7..e683f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added - `Base.literal_pow` definitions for `KVector{1}` that produce `KVector` results. +### Changed + - Natural exponential are only optimized for `KVector` types whose `BitIndices` uniformly square + to the same value. + ### Fixed - `OddCliffordNumber` constructors now fail to operate on scalars unless there is exactly one odd element in the algebra. - Broken bullets in `AbstractCliffordNumber` docstring. - `StackOverflowError` in `KVector{0}` exponentiation. + - Incorrect natural exponentials in algebras with non-uniform sign signatures. ## [0.1.6] - 2024-06-27 diff --git a/src/math/exponential.jl b/src/math/exponential.jl index 500a060..0890bfd 100644 --- a/src/math/exponential.jl +++ b/src/math/exponential.jl @@ -145,11 +145,11 @@ See also: [`exppi`](@ref), [`exptau`](@ref). function exp(x::AbstractCliffordNumber) T = exponential_type(x) Tx = convert(T, x) - sq = mul(Tx, Tx) - if isscalar(sq) - mag = abs(x) - scalar(sq) < 0 && return T(cos(mag)) + Tx * (sin(mag) / mag) - scalar(sq) > 0 && return T(cosh(mag)) + Tx * (sinh(mag) / mag) + # Check that all basis blades of the type square to the same sign, too + if allequal(sign_of_square(b) for b in BitIndices(x)) && isscalar(x^2) + mag = abs(x) # should be faster to calculate directly from input type (it may be shorter) + scalar(x^2) < 0 && return T(cos(mag)) + Tx * (sin(mag) / mag) + scalar(x^2) > 0 && return T(cosh(mag)) + Tx * (sinh(mag) / mag) return one(T) + Tx end return exp_taylor(x)