JuliaManifolds / Manifolds.jl

Manifolds.jl provides a library of manifolds aiming for an easy-to-use and fast implementation.
https://juliamanifolds.github.io/Manifolds.jl
MIT License
376 stars 55 forks source link

Cotangent vectors #261

Open mateuszbaran opened 3 years ago

mateuszbaran commented 3 years ago

After recently reading a bit about use of cotangent vectors in AD (for example here: https://gist.github.com/Keno/4a6507b75288b1fe671e9d1cc683014f ) I think we handle them wrong. Now I think there are only two valid ways to represent them:

  1. a function/functor/something callable that accepts tangent vectors and returns a number,
  2. coordinates in a basis.

At the moment our sharp and flat functions do something different (especially for MetricManifold) and it makes me quite uneasy.

kellertuer commented 3 years ago

Well, some call the functions that we call get_vector(flat) and get_coordinates (sharp) that way, I think, so it agrees with your second idea in that sense.

I think until now we just don't represent them, do we?

mateuszbaran commented 3 years ago

Well, some call the functions that we call get_vector(flat) and get_coordinates (sharp) that way,

I don't quite understand what you mean by that. get_vector and flat don't seem particularly related?

I think until now we just don't represent them, do we?

We mostly don't but still we have things like this: https://github.com/JuliaManifolds/Manifolds.jl/blob/master/src/manifolds/MetricManifold.jl#L614-L618 that don't integrate well with what the rest of Manifolds.jl does with tangent vectors.

kellertuer commented 3 years ago

but that sharp is you 1., just sorting the linear functional using a vector representation.

mateuszbaran commented 3 years ago

No, it's very much not. It's actually sort of my 2nd point. Sort of because I don't see a point in talking about local metric without specifying a basis.

My first point is something we don't have at the moment. In my first point flat would be just taking given tangent vector as a Riesz representer of the cotangent (and wrapping in a struct that indicates this).

kellertuer commented 3 years ago

Ah, right! Then I misread your first variant. I actually like both, in our recent paper we used variant 1, but in the implementation (I am currently finishing), I was lazy and removed all sharp and flats (also since that was possible) and just used tangent vectors.

But it would be very neat to have something like this.

kellertuer commented 4 months ago

We had a discussion today about variant 1 (after I did not look at this for quite some time) – so good that we have this still open. So I would still think this is nice to have if realised in a nice and consistent way.