Skip to content

Commit

Permalink
improved performance of composite methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Mar 7, 2020
1 parent 87d6e5d commit 113b30b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ Exterior product as defined by the anti-symmetric quotient Λ≡⊗/~
@inline (a::TensorAlgebra{V},b::UniformScaling{T}) where {V,T<:Field} = aV(b)
@inline (a::UniformScaling{T},b::TensorAlgebra{V}) where {V,T<:Field} = V(a)b
@generated (t::T) where T<:SVector = Expr(:call,:,[:(t[$k]) for k 1:length(t)]...)
(m::Vector{Chain{V,G,T,X}} where {G,T,X}) where V = [(V[k]) for k value.(m)]
(a::X,b::Y,c::Z...) where {X<:TensorAlgebra,Y<:TensorAlgebra,Z<:TensorAlgebra} = (ab,c...)

export , ,
Expand Down
9 changes: 5 additions & 4 deletions src/composite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,23 @@ end=#
export detsimplex, initmesh

detsimplex(m::Vector{Chain{V,G,T,X}} where {G,T,X}) where V = (m)/factorial(ndims(V)-1)
detsimplex(m::ChainBundle) = detsimplex(value(m))
mean(m::Vector{Chain{V,G,T,X}} where {V,G,T,X}) = sum(m)/length(m)
mean(m::T) where T<:SVector = sum(m)/length(m)
barycenter(m::SVector{N,Chain{V,G,T,X}} where {V,G,T,X}) where N = (s=sum(m);s/s[1])
barycenter(m::Vector{Chain{V,G,T,X}} where {V,G,T,X}) = (s=sum(m);s/s[1])
curl(m::SVector{N,Chain{V,G,T,X}} where {N,G,T,X}) where V = curl(Chain{V,1}(m))
curl(m::T) where T<:TensorAlgebra = Manifold(m)(∇)×m
for op (:,:detsimplex)
@eval @pure $op(m::ChainBundle) = ChainBundle($op(value(m)))
end
LinearAlgebra.det(V::ChainBundle,m::Vector) = .∧(getindex.(Ref(V),value.(m)))
(m::Vector{Chain{V,G,T,X}} where {G,T,X}) where V = LinearAlgebra.det(V,m)
(m::ChainBundle) = LinearAlgebra.det(Manifold(m),value(m))
for op (:mean,:barycenter,:curl)
ops = Symbol(op,:s)
@eval begin
export $op, $ops
@pure $ops(m::ChainBundle{p}) where p = $ops(m,p)
@pure $ops(m::ChainBundle,::SubManifold{p}) where p = $ops(m,p)
@pure $ops(m::ChainBundle,p) = [$op(p[k]) for k value.(value(m))]
@pure $ops(m::ChainBundle,p) = $op.(getindex.(Ref(p),value.(value(m))))
end
end

Expand Down

0 comments on commit 113b30b

Please sign in to comment.