From 010bac37234a60eda916f1eb7c484d4240b34707 Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Mon, 2 Jul 2018 12:50:19 +0200 Subject: [PATCH] Import mean from Statistics on 0.7. --- src/Rotations.jl | 6 ++++++ src/mean.jl | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Rotations.jl b/src/Rotations.jl index 1ecdd716..805943d1 100644 --- a/src/Rotations.jl +++ b/src/Rotations.jl @@ -10,6 +10,12 @@ using StaticArrays import Base: convert, eltype, size, length, getindex, *, Tuple import Compat.LinearAlgebra: inv, eye +if VERSION >= v"0.7.0-beta.85" + import Statistics: mean +else + import Base: mean +end + include("util.jl") include("core_types.jl") include("quaternion_types.jl") diff --git a/src/mean.jl b/src/mean.jl index e97b25e5..1985060a 100644 --- a/src/mean.jl +++ b/src/mean.jl @@ -29,7 +29,7 @@ Args: Find the mean `r̄` of a set of rotations `r`. The returned rotation minimizes `sum_i=1:n (||r[i] - r̄||)` with `||` the Frobenius norm, or equivalently minimizes `sum_i=1:n (sin(ϕ[i] / 2))^2`, where `ϕ[i] = rotation_angle(r[i] / r̄)`. """ -function Base.mean(qvec::AbstractVector{Quat{T}}, method::Integer = 0) where T +function mean(qvec::AbstractVector{Quat{T}}, method::Integer = 0) where T #if (method == 0) M = zeros(4, 4) for i = 1:length(qvec) @@ -46,6 +46,6 @@ function Base.mean(qvec::AbstractVector{Quat{T}}, method::Integer = 0) where T return Qbar end -function Base.mean(vec::AbstractVector{R}) where R<:Rotation +function mean(vec::AbstractVector{R}) where R<:Rotation R(mean(convert(Vector{Quat{eltype(R)}}, vec))) end