Skip to content

Commit

Permalink
Fixes Nested PowerManifold of a PowerManifold to not concatenate size…
Browse files Browse the repository at this point in the history
…s. (#235)

* specify that Nested of a Powermanifold yields a powermanifold within a powermanifold and does not concatenate sizes.
  • Loading branch information
kellertuer authored Oct 10, 2020
1 parent 4fbb2d3 commit e9b7102
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/manifolds/PowerManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ dimensions will be appended to the dimensions already present, for example
`PowerManifold(PowerManifold(Sphere(2), 2), 3)` is equivalent to
`PowerManifold(Sphere(2), 2, 3)`. This feature preserves the representation of the inner
power manifold (unless it's explicitly overridden).
If you specify `NestedPowerRepresentation()`, the sizes are not concatenated but you end up
with a nested power manifold within a power manifold.
"""
struct PowerManifold{𝔽,TM<:Manifold{𝔽},TSize,TPR<:AbstractPowerRepresentation} <:
AbstractPowerManifold{𝔽,TM,TPR}
Expand Down Expand Up @@ -98,7 +100,20 @@ function PowerManifold(
) where {𝔽,TM<:Manifold{𝔽},TSize,TPR<:AbstractPowerRepresentation}
return PowerManifold{𝔽,TM,Tuple{TSize.parameters...,size...},TPR}(M.manifold)
end

function PowerManifold(
M::PowerManifold{𝔽,TM,TSize},
::NestedPowerRepresentation,
size::Integer...,
) where {𝔽,TM<:Manifold{𝔽},TSize}
return PowerManifold{
𝔽,
PowerManifold{𝔽,TM,TSize},
Tuple{size...},
NestedPowerRepresentation,
}(
M,
)
end
@doc raw"""
PowerMetric <: Metric
Expand Down
4 changes: 4 additions & 0 deletions test/power_manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Random.seed!(42)
Ms2 = PowerManifold(Ms, 5, 7)
@test power_dimensions(Ms2) == (5, 7)
@test manifold_dimension(Ms2) == 70
Ms2n = PowerManifold(Ms1, NestedPowerRepresentation(), 7)
@test power_dimensions(Ms2n) == (7,)
@test manifold_dimension(Ms2n) == 70

Mr = Manifolds.Rotations(3)
Mr1 = PowerManifold(Mr, 5)
Mrn1 = PowerManifold(Mr, Manifolds.NestedPowerRepresentation(), 5)
Expand Down

0 comments on commit e9b7102

Please sign in to comment.