From 6047b4ab892353913dc00b568836b4dd7be72690 Mon Sep 17 00:00:00 2001 From: Brandon Flores Date: Mon, 11 Nov 2024 14:32:51 -0600 Subject: [PATCH] Added `AbstractCliffordNumber{Q,T}(::AbstractCliffordNumber{Q})` constructor that converts scalar type --- src/abstract.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/abstract.jl b/src/abstract.jl index 206f74e..4939ab6 100644 --- a/src/abstract.jl +++ b/src/abstract.jl @@ -164,6 +164,12 @@ similar_type(x, Q::Val) = similar_type(x, scalar_type(x), Q) similar(C::Type{<:AbstractCliffordNumber}, args...) = zero(similar_type(C, args...)) similar(x::AbstractCliffordNumber, args...) = zero(similar_type(x, args...)) +# Perform conversion of the scalar type +# UNDERSTAND: The type constraint on T is required. Why? +function AbstractCliffordNumber{Q,T}(x::AbstractCliffordNumber{Q}) where {Q,T<:BaseNumber} + return similar_type(x, T)(x) +end + """ CliffordNumbers.complement_type(C::Type{<:AbstractCliffordNumber}) CliffordNumbers.complement_type(x::AbstractCliffordNumber)