Skip to content

Commit

Permalink
Hyperbolic Riemann tensor (#651)
Browse files Browse the repository at this point in the history
* Adds Riemann tensor on hyperbolic space
* Adds formula reference
* Adds test
* Bump version
* Add myself to contributors list
* Runs formatter
* Adds test for inplace method
* Rewrites formula 
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
* Simplify inplace computation
* Fix naming
---------
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
  • Loading branch information
hajg-ijk authored Sep 20, 2023
1 parent 22dc01d commit b5cdb3c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"contributors": [
{
"affiliation": "NTNU Trondheim",
"name": "Jasa, Hajg",
"type": "ProjectMember",
"orcid": "0009-0002-7917-0530"
},
{
"name": "Mathieu Besançon",
"type": "Other",
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Manifolds"
uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
authors = ["Seth Axen <seth.axen@gmail.com>", "Mateusz Baran <mateuszbaran89@gmail.com>", "Ronny Bergmann <manopt@ronnybergmann.net>", "Antoine Levitt <antoine.levitt@gmail.com>"]
version = "0.8.76"
version = "0.8.77"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
10 changes: 9 additions & 1 deletion docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,14 @@ @article{LorenziPennec:2013
TITLE = {Efficient Parallel Transport of Deformations in Time Series of Images: From Schild's to Pole Ladder},
JOURNAL = {Journal of Mathematical Imaging and Vision}
}
@book{Lee:2019,
AUTHOR = {John M. Lee},
DOI = {10.1007/978-3-319-91755-9},
ISBN = {978-3-319-91755-9},
PUBLISHER = {Springer Cham},
TITLE = {Introduction to Riemannian Manifolds},
YEAR = {2019}
}
#
# M
# ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -667,7 +675,7 @@ @book{SrivastavaKlassen:2016
AUTHOR = {Anuj Srivastava and Eric P. Klassen},
DOI = {10.1007/978-1-4939-4020-2},
ISBN = {978-1-4939-4018-9},
PUBLISHER = {Springer NEw York},
PUBLISHER = {Springer New York},
TITLE = {Functional and Shape Data Analysis},
YEAR = {2016}
}
Expand Down
17 changes: 17 additions & 0 deletions src/manifolds/Hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,20 @@ for (P, T) in zip(_ExtraHyperbolicPointTypes, _ExtraHyperbolicTangentTypes)
@eval zero_vector(::Hyperbolic, p::$P) = $T(zero(p.value))
@eval zero_vector!(::Hyperbolic, X::$T, ::$P) = fill!(X.value, 0)
end

@doc raw"""
riemann_tensor(M::Hyperbolic{n}, p, X, Y, Z)
Compute the Riemann tensor ``R(X,Y)Z`` at point `p` on [`Hyperbolic`](@ref) `M`.
The formula reads (see e.g., [Lee:2019](@cite) Proposition 8.36)
````math
R(X,Y)Z = - (\langle Z, Y \rangle X - \langle Z, X \rangle Y)
````
"""
riemann_tensor(::Hyperbolic, p, X, Y, Z)

function riemann_tensor!(M::Hyperbolic, W, p, X, Y, Z)
W .= inner(M, p, Z, X) .* Y .- inner(M, p, Z, Y) .* X
return W
end
20 changes: 20 additions & 0 deletions test/manifolds/hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,26 @@ include("../utils.jl")
A = change_metric(M, MinkowskiMetric(), p, X)
@test A == X
end
@testset "other metric" begin
M = Hyperbolic(2)
@test riemann_tensor(
M,
[0.0, 0.0, -1.0],
[-1.0, 0.0, 0.0],
[0.0, -1.0, 0.0],
[-0.5, -0.5, 0.0],
) == [0.5, -0.5, 0.0]
X = [0.0, 0.0, 0.0]
@test riemann_tensor!(
M,
X,
[0.0, 0.0, -1.0],
[-1.0, 0.0, 0.0],
[0.0, -1.0, 0.0],
[-0.5, -0.5, 0.0],
) === X
@test X == [0.5, -0.5, 0.0]
end
@testset "ManifoldDiff" begin
# ManifoldDiff
M = Hyperbolic(2)
Expand Down

2 comments on commit b5cdb3c

@kellertuer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/91757

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.77 -m "<description of version>" b5cdb3c2636caca80ec0ed60425172f503828d77
git push origin v0.8.77

Please sign in to comment.