Skip to content

Commit

Permalink
Merge pull request #60 from FugroRoames/tk/mean
Browse files Browse the repository at this point in the history
Import mean from Statistics on 0.7.
  • Loading branch information
andyferris authored Jul 2, 2018
2 parents e3273cc + 010bac3 commit 531a633
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Rotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/mean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 531a633

Please sign in to comment.