Skip to content

Commit

Permalink
general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Jun 29, 2019
1 parent eaef0bc commit d8f1766
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/ArrayManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ end
convert(::Type{M},m::ArrayManifold{M}) where M <: Manifold = m.manifold
convert(::Type{ArrayManifold{M}},m::M) where M <: Manifold = ArrayManifold(M)

function representation_size(M::ArrayManifold, ::Type{T}) where {T}
return representation_size(M.manifold, T)
end

manifold_dimension(M::ArrayManifold) = manifold_dimension(M.manifold)

@traitimpl IsDecoratorManifold{ArrayManifold}
Expand Down
8 changes: 7 additions & 1 deletion src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ function manifold_dimension end
The size of array representing an object of type `T` on manifold `M`,
for example point, tangent vector or cotangent vector.
"""
function representation_size(M::Manifold, ::Type{T}) where {T}
function representation_size end

@traitfn function representation_size(M::MT, ::Type{T}) where {MT<:Manifold,T;!IsDecoratorManifold{MT}}
error("representation_size not implemented for manifold $(typeof(M)) and type $(T).")
end

@traitfn function representation_size(M::MT, ::Type{T}) where {MT<:Manifold,T;IsDecoratorManifold{MT}}
return representation_size(base_manifold(M), T)
end

@traitfn function manifold_dimension(M::MT) where {MT<:Manifold;!IsDecoratorManifold{MT}}
error("manifold_dimension not implemented for a $(typeof(M)).")
end
Expand Down
5 changes: 0 additions & 5 deletions src/Metric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ struct MetricManifold{M<:Manifold,G<:Metric} <: Manifold
metric::G
end

function representation_size(M::MetricManifold, ::Type{T}) where {T}
return representation_size(M.manifold, T)
end


convert(::Type{MT},M::MetricManifold{MT,GT}) where {MT,GT} = M.manifold

@traitimpl IsDecoratorManifold{MetricManifold}
Expand Down
4 changes: 2 additions & 2 deletions src/ProductManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

function ProductManifold(manifolds...)
sizes = map(m -> representation_size(m, MPoint), manifolds)
lengths = map(s -> prod(s), sizes)
lengths = map(prod, sizes)
ranges = UnitRange{Int64}[]
k = 1
for len lengths
Expand All @@ -31,7 +31,7 @@ function ProductManifold(manifolds...)
end

function representation_size(M::ProductManifold, ::Type{T}) where {T}
return (sum(map(m -> representation_size(m, T), M.manifolds)),)
return (mapreduce(m -> representation_size(m, T), +, M.manifolds),)
end

manifold_dimension(M::ProductManifold) = sum(map(m -> manifold_dimension(m), M.manifolds))
Expand Down

0 comments on commit d8f1766

Please sign in to comment.