From c6bc215a6c7d8f9ec083b75084433a13ee837751 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 17 Sep 2022 03:14:43 +0900 Subject: [PATCH] update quat(::Array) to return Array{<:Quaternion} --- src/Quaternion.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Quaternion.jl b/src/Quaternion.jl index 60872785..1f682564 100644 --- a/src/Quaternion.jl +++ b/src/Quaternion.jl @@ -45,6 +45,12 @@ quat(p, v1, v2, v3) = Quaternion(p, v1, v2, v3) quat(p, v1, v2, v3, n) = Quaternion(p, v1, v2, v3, n) quat(x) = Quaternion(x) quat(s, a) = Quaternion(s, a) +function quat(A::AbstractArray{T}) where T + if !isconcretetype(T) + error("`quat` not defined on abstractly-typed arrays; please convert to a more specific type") + end + convert(AbstractArray{typeof(quat(zero(T)))}, A) +end real(::Type{Quaternion{T}}) where {T} = T real(q::Quaternion) = q.s