Repository: JuliaManifolds/ManifoldsBase.jl
Pull request #142 (2023-01-08 17:15:21)

Basic definitions for metrics
As discussed here: https://github.com/JuliaManifolds/ManifoldDiff.jl/pull/12 .

codecov[bot]: # [Codecov](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds) Report
> Merging [#142](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds) (6156dc0) into [master](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/commit/0956a918a6d645a2a0b7b7b1890fa6b99444c491?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds) (0956a91) will **decrease** coverage by `7.52%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master     #142      +/-   ##
==========================================
- Coverage   99.79%   92.26%   -7.53%     
==========================================
  Files          18       19       +1     
  Lines        2451     1539     -912     
==========================================
- Hits         2446     1420    -1026     
- Misses          5      119     +114     
```


| [Impacted Files](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds) | Coverage Δ | |
|---|---|---|
| [src/ManifoldsBase.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL01hbmlmb2xkc0Jhc2Uuamw=) | `97.02% <ø> (-2.53%)` | :arrow_down: |
| [src/metric.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL21ldHJpYy5qbA==) | `100.00% <100.00%> (ø)` | |
| [src/EmbeddedManifold.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL0VtYmVkZGVkTWFuaWZvbGQuamw=) | `60.00% <0.00%> (-40.00%)` | :arrow_down: |
| [src/decorator\_trait.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL2RlY29yYXRvcl90cmFpdC5qbA==) | `70.32% <0.00%> (-29.68%)` | :arrow_down: |
| [src/nested\_trait.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL25lc3RlZF90cmFpdC5qbA==) | `79.16% <0.00%> (-20.84%)` | :arrow_down: |
| [src/point\_vector\_fallbacks.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL3BvaW50X3ZlY3Rvcl9mYWxsYmFja3Muamw=) | `80.45% <0.00%> (-18.80%)` | :arrow_down: |
| [src/ValidationManifold.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL1ZhbGlkYXRpb25NYW5pZm9sZC5qbA==) | `90.65% <0.00%> (-9.35%)` | :arrow_down: |
| [src/errors.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL2Vycm9ycy5qbA==) | `93.33% <0.00%> (-6.67%)` | :arrow_down: |
| [src/DefaultManifold.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL0RlZmF1bHRNYW5pZm9sZC5qbA==) | `93.47% <0.00%> (-6.53%)` | :arrow_down: |
| [src/shooting.jl](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds#diff-c3JjL3Nob290aW5nLmps) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |
| ... and [10 more](https://codecov.io/gh/JuliaManifolds/ManifoldsBase.jl/pull/142?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds) | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaManifolds)


Patch:
diff --git a/Project.toml b/Project.toml
index 13c929b1..2ee7eb6f 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "ManifoldsBase"
 uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
 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.13.28"
+version = "0.13.29"
 
 [deps]
 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
diff --git a/docs/src/manifolds.md b/docs/src/manifolds.md
index 4a437a00..2f867ba2 100644
--- a/docs/src/manifolds.md
+++ b/docs/src/manifolds.md
@@ -61,3 +61,13 @@ Modules = [ManifoldsBase]
 Pages = ["EmbeddedManifold.jl"]
 Order = [:type, :macro, :function]
 ```
+
+## Metrics
+
+Most metric-related functionality is currently defined in [`Manifolds.jl`](https://juliamanifolds.github.io/Manifolds.jl/latest/) but a few basic types are defined here.
+
+```@autodocs
+Modules = [ManifoldsBase]
+Pages = ["metric.jl"]
+Order = [:type, :function]
+```
diff --git a/src/ManifoldsBase.jl b/src/ManifoldsBase.jl
index 3ccf53c3..678f971a 100644
--- a/src/ManifoldsBase.jl
+++ b/src/ManifoldsBase.jl
@@ -31,6 +31,7 @@ include("bases.jl")
 include("retractions.jl")
 include("exp_log_geo.jl")
 include("projections.jl")
+include("metric.jl")
 
 """
     allocate(a)
diff --git a/src/metric.jl b/src/metric.jl
new file mode 100644
index 00000000..59b9bda8
--- /dev/null
+++ b/src/metric.jl
@@ -0,0 +1,41 @@
+@doc raw"""
+    AbstractMetric
+
+Abstract type for the pseudo-Riemannian metric tensor ``g``, a family of smoothly
+varying inner products on the tangent space. See [`inner`](@ref).
+
+# Functor
+
+    (metric::Metric)(M::AbstractManifold)
+    (metric::Metric)(M::MetricManifold)
+
+Generate the `MetricManifold` that wraps the manifold `M` with given `metric`.
+This works for both a variable containing the metric as well as a subtype `T<:AbstractMetric`,
+where a zero parameter constructor `T()` is availabe.
+If `M` is already a metric manifold, the inner manifold with the new `metric` is returned.
+"""
+abstract type AbstractMetric end
+
+@doc raw"""
+    RiemannianMetric <: AbstractMetric
+
+Abstract type for Riemannian metrics, a family of positive definite inner
+products. The positive definite property means that for ``X  ∈ T_p \mathcal M``, the
+inner product ``g(X, X) > 0`` whenever ``X`` is not the zero vector.
+"""
+abstract type RiemannianMetric <: AbstractMetric end
+
+"""
+    EuclideanMetric <: RiemannianMetric
+
+A general type for any manifold that employs the Euclidean Metric, for example
+the [`Euclidean`](@ref) manifold itself, or the [`Sphere`](@ref), where every
+tangent space (as a plane in the embedding) uses this metric (in the embedding).
+
+Since the metric is independent of the field type, this metric is also used for
+the Hermitian metrics, i.e. metrics that are analogous to the `EuclideanMetric`
+but where the field type of the manifold is `ℂ`.
+
+This metric is the default metric for example for the [`Euclidean`](@ref) manifold.
+"""
+struct EuclideanMetric <: RiemannianMetric end


Test patch:
diff --git a/test/metric.jl b/test/metric.jl
new file mode 100644
index 00000000..4eeb81b4
--- /dev/null
+++ b/test/metric.jl
@@ -0,0 +1,6 @@
+using Test
+using ManifoldsBase
+
+@testset "Metrics" begin
+    @test ManifoldsBase.EuclideanMetric() isa ManifoldsBase.AbstractMetric
+end
diff --git a/test/runtests.jl b/test/runtests.jl
index c4f71626..22017503 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -34,4 +34,5 @@ using ManifoldsBase
     include("power.jl")
     include("domain_errors.jl")
     include("vector_transport.jl")
+    include("metric.jl")
 end