JuliaManifolds / ManifoldsBase.jl

Basic interface for manifolds in Julia
https://juliamanifolds.github.io/ManifoldsBase.jl/
MIT License
87 stars 8 forks source link

Sectional curvature #184

Closed mateuszbaran closed 6 months ago

mateuszbaran commented 6 months ago

Adapted from Manopt.jl, with added functions for lower and upper bounds.

kellertuer commented 6 months ago

This looks very nice! Thanks for adapting that.

If the test coverage is fine, I am ok with this.

mateuszbaran commented 6 months ago

Question: should sectional_curvature return 0 for non-linearly independent vectors X, Y or be undefined? Making it 0 makes it much easier to define sectional_curvature on power and product manifolds but makes it harder to properly define the generic fallback that uses riemann_tensor.

kellertuer commented 6 months ago

Why is that harder for the Riemannian tensor? I would have thought it is either undefined or zero.

mateuszbaran commented 6 months ago

The formula inner(M, p, R, X) / ((norm(M, p, X)^2 * norm(M, p, Y)^2) - (inner(M, p, X, Y)^2)) is 0 / 0 when X and Y are linearly dependent. We can either detect this situation and return 0 (which requires adding a cut-off due to numerical inaccuracy) or say "don't use linearly dependent vectors".

kellertuer commented 6 months ago

I think the clearer way would be “we do not use linearly dependent vectors”?

mateuszbaran commented 6 months ago

That's how it currently works.

kellertuer commented 6 months ago

Ah, yes. I see. And it is also well-documented that way. I think it is ok to keep it that way.

mateuszbaran commented 6 months ago

OK, then we need a test for linear independence in sectional_curvature of ProductManifold. I don't really have a nice idea for that, maybe something like norm(M, p, X) < eps(...) || norm(M, p, Y) < eps(...) || isapprox(inner(M, p, X, Y), norm(M, p, X)*norm(M, p, Y)) || isapprox(inner(M, p, X, Y), -norm(M, p, X)*norm(M, p, Y))?

mateuszbaran commented 6 months ago

Or we can just leave that not implemented for now.

kellertuer commented 6 months ago

I would thoroughly document that we assume they are linearly independent – and for now not implement a check.

mateuszbaran commented 6 months ago

It doesn't work for product manifolds though. You may have two vectors that are linearly independent, but their projections on one or more of the component manifolds are not linearly independent, so that needs to be handled somewhere since sectional curvature for them is well-defined.

kellertuer commented 6 months ago

But then one could check that on every “manifold factor” and only add that to the min if they are linearly independent and ignore them otherwise?

mateuszbaran commented 6 months ago

Yes, that's what would be needed.

kellertuer commented 6 months ago

This looks good so far. I am just missing the good old code coverage – did we miss to update the GitHub action? I remember something like this in a recent PR either on Manopt or Manifolds as well that I had to specifically add the secret (again) to the action.

kellertuer commented 6 months ago

ah cf. https://github.com/JuliaManifolds/Manopt.jl/pull/357/commits/5d7646fbd0650da15d8d4bbe997fde29b4763af7

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.96%. Comparing base (b7665ae) to head (08abaef). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #184 +/- ## ======================================= Coverage 99.96% 99.96% ======================================= Files 27 27 Lines 3107 3156 +49 ======================================= + Hits 3106 3155 +49 Misses 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mateuszbaran commented 6 months ago

Right, I somehow didn't notice the lack of coverage report. It works now. I think we can merge this now?