Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Power manifold #40

Merged
merged 27 commits into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a16f1e4
improved SizedAbstractArray
mateuszbaran Aug 17, 2019
ad3b3f1
some work on getindex for sized abstract array
mateuszbaran Aug 19, 2019
10b2f5a
decently working getindex for dynamically sized abstract array
mateuszbaran Aug 30, 2019
4ea8097
split of fully static and hybrid static-dynamic arrays
mateuszbaran Aug 31, 2019
5d11524
some work on setindex! for HybridAbstractArray
mateuszbaran Aug 31, 2019
b95189f
lots of work on HybridAbstractArray broadcasting
mateuszbaran Sep 6, 2019
734ad18
next part of work on HybridArray
mateuszbaran Sep 9, 2019
4b37733
HybridArray separated into a new package (WIP)
mateuszbaran Sep 20, 2019
6665680
power manifold WIP
mateuszbaran Oct 9, 2019
86c4b92
power manifold WIP pt 2
mateuszbaran Oct 9, 2019
cbc9a04
HybridArrays added as a dependency
mateuszbaran Oct 14, 2019
fdd7c00
conflict resolution
mateuszbaran Oct 14, 2019
d48ae2c
Merge remote-tracking branch 'refs/remotes/origin/master'
mateuszbaran Oct 18, 2019
d7927d2
Correction in docs for PowerManifold
mateuszbaran Oct 21, 2019
cc8752d
support for distributions on tangent space to a power manifold
mateuszbaran Oct 25, 2019
30f760c
multi-index power manifolds
mateuszbaran Oct 25, 2019
2563c5a
power manifolds of manifolds represented by multi-index arrays
mateuszbaran Oct 30, 2019
674baa0
some performance improvements for power manifolds
mateuszbaran Oct 31, 2019
6c571a2
cleaner and faster power manifolds
mateuszbaran Nov 3, 2019
f2db354
power manifold benchmarks
mateuszbaran Nov 3, 2019
4433e25
musical isomorphisms for power manifolds
mateuszbaran Nov 3, 2019
5714d47
removed Size() constructor for SizedAbstractArray
mateuszbaran Nov 3, 2019
967e445
docs for power manifold
mateuszbaran Nov 3, 2019
00e79d8
a new test for injectivity_radius
mateuszbaran Nov 4, 2019
733947c
missing test file include added
mateuszbaran Nov 4, 2019
ab0f48a
HybridArrays compatibility bound changed
mateuszbaran Nov 4, 2019
de6d7f3
constructor of PowerManifold changed
mateuszbaran Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "0.1.0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Einsum = "b7d42ee7-0b51-5a75-98ca-779d3107e4c0"
HybridArrays = "1baab800-613f-4b0a-84e4-9cd3431bfbb9"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -15,6 +16,11 @@ SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
UnsafeArrays = "c4a57d5a-5b31-53a6-b365-19f8c011fbd6"

[compat]
DoubleFloats = ">= 0.9.2"
HybridArrays = ">= 0.3"
julia = "1.0"

[extras]
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand All @@ -24,7 +30,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "DoubleFloats", "ForwardDiff", "OrdinaryDiffEq", "ReverseDiff"]

[compat]
julia = "1.0"
DoubleFloats = ">= 0.9.2"
64 changes: 64 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Manifolds
using BenchmarkTools
using StaticArrays
using HybridArrays
using LinearAlgebra
using Random

Expand Down Expand Up @@ -152,6 +153,69 @@ function add_manifold_benchmarks()
test_tangent_vector_broadcasting = false)
end

# power manifolds
begin
Ms = Sphere(2)
Ms1 = PowerManifold(Ms, 5)
Ms2 = PowerManifold(Ms, 5, 7)
Mr = Manifolds.Rotations(3)
Mr1 = PowerManifold(Mr, 5)
Mr2 = PowerManifold(Mr, 5, 7)

types_s1 = [Array{Float64,2},
HybridArray{Tuple{3,StaticArrays.Dynamic()}, Float64, 2}]
types_s2 = [Array{Float64,3},
HybridArray{Tuple{3,StaticArrays.Dynamic(),StaticArrays.Dynamic()}, Float64, 3}]

types_r1 = [Array{Float64,3},
HybridArray{Tuple{3,3,StaticArrays.Dynamic()}, Float64, 3}]
types_r2 = [Array{Float64,4},
HybridArray{Tuple{3,3,StaticArrays.Dynamic(),StaticArrays.Dynamic()}, Float64, 4}]

retraction_methods = [Manifolds.PowerRetraction(Manifolds.ExponentialRetraction())]
inverse_retraction_methods = [Manifolds.InversePowerRetraction(Manifolds.LogarithmicInverseRetraction())]

sphere_dist = Manifolds.uniform_distribution(Ms, @SVector [1.0, 0.0, 0.0])
power_s1_pt_dist = Manifolds.PowerPointDistribution(Ms1, sphere_dist, randn(Float64, 3, 5))
power_s2_pt_dist = Manifolds.PowerPointDistribution(Ms2, sphere_dist, randn(Float64, 3, 5, 7))
sphere_tv_dist = Manifolds.normal_tvector_distribution(Ms, (@MVector [1.0, 0.0, 0.0]), 1.0)
power_s1_tv_dist = Manifolds.PowerFVectorDistribution(TangentBundleFibers(Ms1), rand(power_s1_pt_dist), sphere_tv_dist)
power_s2_tv_dist = Manifolds.PowerFVectorDistribution(TangentBundleFibers(Ms2), rand(power_s2_pt_dist), sphere_tv_dist)

id_rot = @SMatrix [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0]
rotations_dist = Manifolds.normal_rotation_distribution(Mr, id_rot, 1.0)
power_r1_pt_dist = Manifolds.PowerPointDistribution(Mr1, rotations_dist, randn(Float64, 3, 3, 5))
power_r2_pt_dist = Manifolds.PowerPointDistribution(Mr2, rotations_dist, randn(Float64, 3, 3, 5, 7))
rotations_tv_dist = Manifolds.normal_tvector_distribution(Mr, MMatrix(id_rot), 1.0)
power_r1_tv_dist = Manifolds.PowerFVectorDistribution(TangentBundleFibers(Mr1), rand(power_r1_pt_dist), rotations_tv_dist)
power_r2_tv_dist = Manifolds.PowerFVectorDistribution(TangentBundleFibers(Mr2), rand(power_r2_pt_dist), rotations_tv_dist)

trim(s::String) = s[1:min(length(s), 20)]

for T in types_s1
pts1 = [convert(T, rand(power_s1_pt_dist)) for _ in 1:3]
add_manifold(Ms1, pts1, "power manifold S²^(5,), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true)
end
for T in types_s2
pts2 = [convert(T, rand(power_s2_pt_dist)) for _ in 1:3]
add_manifold(Ms2, pts2, "power manifold S²^(5,7), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true)
end

for T in types_r1
pts1 = [convert(T, rand(power_r1_pt_dist)) for _ in 1:3]
add_manifold(Mr1, pts1, "power manifold SO(3)^(5,), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true)
end
for T in types_r2
pts2 = [convert(T, rand(power_r2_pt_dist)) for _ in 1:3]
add_manifold(Mr2, pts2, "power manifold SO(3)^(5,7), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true)
end

end

end

add_manifold_benchmarks()
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ makedocs(
"Sphere" => "manifolds/sphere.md"
],
"Combined manifolds" => [
"Power manifold" => "manifolds/power.md",
"Product manifold" => "manifolds/product.md",
"Vector bundle" => "manifolds/vector_bundle.md"
],
Expand Down
3 changes: 3 additions & 0 deletions docs/src/lib/public.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ submanifold_component
Manifolds.ProductArray
ProductRepr
Manifolds.prod_point
Manifolds.StaticReshaper
Manifolds.ArrayReshaper
Manifolds.make_reshape
```
9 changes: 9 additions & 0 deletions docs/src/manifolds/power.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Product Manifold

Power manifold $P = M^{N_1 \times N_2 \times \dots \times N_n}$ of manifold $N$ with shape $N_1 \times N_2 \times \dots \times N_n$. Canonical projections may depend on multiple indices $i_1, i_2, \dots, i_n$. For example, manifold-valued time series require a single index ($n=1$) and manifold-valued images require two indices ($n=2$).

```@autodocs
Modules = [Manifolds]
Pages = ["PowerManifold.jl"]
Order = [:type, :function]
```
9 changes: 8 additions & 1 deletion src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import Base: isapprox,
getindex,
setindex!,
size,
length,
copy,
copyto!,
convert,
dataids,
axes,
promote_rule,
+,
-,
*
Expand All @@ -25,6 +28,7 @@ import LinearAlgebra: dot,
Diagonal
using Requires
using StaticArrays
using HybridArrays
import Markdown: @doc_str
import Distributions: _rand!, support
import Random: rand
Expand Down Expand Up @@ -517,7 +521,7 @@ vectors shorter than $d$ (has a left inverse).
injectivity_radius(M::Manifold, x, ::AbstractRetractionMethod) = injectivity_radius(M, x)

"""
injectivity_radius(M::Manifold, x)
injectivity_radius(M::Manifold)

Infimum of the injectivity radii of all manifold points.
"""
Expand Down Expand Up @@ -625,6 +629,7 @@ is_tangent_vector(M::Manifold, x, v; kwargs...) = true
is_tangent_vector(M::Manifold, x::MPoint, v::TVector) = error("A validation for a $(typeof(v)) in the tangent space of a $(typeof(x)) on $(typeof(M)) not implemented.")

include("utils.jl")
include("SizedAbstractArray.jl")

include("ProductRepresentations.jl")
include("ArrayManifold.jl")
Expand All @@ -634,6 +639,7 @@ include("DistributionsBase.jl")
include("Metric.jl")
include("Euclidean.jl")
include("ProductManifold.jl")
include("PowerManifold.jl")
include("Rotations.jl")
include("Sphere.jl")
include("ProjectedDistribution.jl")
Expand Down Expand Up @@ -662,6 +668,7 @@ export Manifold,
Euclidean,
Sphere,
ProductManifold,
PowerManifold,
ProductRepr,
VectorSpaceType,
TangentSpace,
Expand Down
Loading