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

Bases of vector spaces #59

Merged
merged 43 commits into from
May 19, 2021
Merged

Bases of vector spaces #59

merged 43 commits into from
May 19, 2021

Conversation

mateuszbaran
Copy link
Member

Some work on adding bases of cotangent spaces. This is supposed to solve problems with flat! and sharp! from this PR: JuliaManifolds/Manifolds.jl#325 .

@codecov
Copy link

codecov bot commented Jan 17, 2021

Codecov Report

Merging #59 (03094a5) into master (e1babe4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #59   +/-   ##
=======================================
  Coverage   99.69%   99.70%           
=======================================
  Files          10       11    +1     
  Lines        1320     1342   +22     
=======================================
+ Hits         1316     1338   +22     
  Misses          4        4           
Impacted Files Coverage Δ
src/DecoratorManifold.jl 100.00% <100.00%> (ø)
src/DefaultManifold.jl 100.00% <100.00%> (ø)
src/EmbeddedManifold.jl 99.30% <100.00%> (-0.02%) ⬇️
src/ManifoldsBase.jl 99.43% <100.00%> (+0.03%) ⬆️
src/PowerManifold.jl 99.14% <100.00%> (-0.02%) ⬇️
src/ValidationManifold.jl 100.00% <100.00%> (ø)
src/bases.jl 100.00% <100.00%> (ø)
src/numbers.jl 100.00% <100.00%> (ø)
src/vector_spaces.jl 100.00% <100.00%> (ø)
src/vector_transport.jl 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1babe4...03094a5. Read the comment docs.

Copy link
Member

@kellertuer kellertuer left a comment

Choose a reason for hiding this comment

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

So this basically introduces a second parameter to the basis indicating what the basis is for? Looks ok to me, I just noticed a minor rephrasing of an error message we could do.

),
" Usually this is implemented for a ",
$(argtypes[1]),
". Maybe you missed to implement this function for a default?",
Copy link
Member

Choose a reason for hiding this comment

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

“this function for a default” – you are referring to a default type? Otherwise one could also write „a default for this function“.

Copy link
Member Author

Choose a reason for hiding this comment

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

This text was there before. Now I'm not quite sure what was it supposed to say.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I did not notice that; we could still rephrase it :)

Copy link
Member

@kellertuer kellertuer left a comment

Choose a reason for hiding this comment

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

Sorry I did not want to approve this, since tests are still missing,

@mateuszbaran
Copy link
Member Author

So this basically introduces a second parameter to the basis indicating what the basis is for? Looks ok to me, I just noticed a minor rephrasing of an error message we could do.

Yes, it's essentialy this, as well as moving FVector to ManifoldsBase.jl and adding a field in it for the basis. The new parameter for basis is not entirely necessary but it looked weird to have a basis and not knowing what kind of space it is a basis of.

@kellertuer
Copy link
Member

Since it is backwards compatible, I think it's fine to add the parameter.

@mateuszbaran
Copy link
Member Author

I just noticed that the vector space is indeed needed in the basis, to be able to correctly interpret coordinates in get_vector.

@kellertuer
Copy link
Member

That's why I carefully asked – we can surely keep in that order and yes, ambiguity fighting is not nice, for sure. Thanks for the explanations.

Yes, that's equivalent, I can use this instead of <:Any.

Great. I think that looks a little nicer

@mateuszbaran
Copy link
Member Author

Non-implemented error messages are quite unhelpful when debugging wrong invokes. I've removed one, maybe we should remove all of them?

@kellertuer
Copy link
Member

We discussed that anyways following Lyndons notes, I would say it's reasonable to remove them, yes.

@mateuszbaran mateuszbaran marked this pull request as ready for review February 19, 2021 10:49
@mateuszbaran
Copy link
Member Author

I think this is ready now. The one new coverage failure looks like a false positive.

@mateuszbaran
Copy link
Member Author

While improving documentation I noticed that vector_space_dimension is referenced in ManifoldsBase.jl but defined in Manifolds.jl. I think we could change its signature to make it take separately manifold and vector space type and move it to ManifoldsBase.jl as well.

@mateuszbaran
Copy link
Member Author

OK. I think we don't need both is_manifold_point and is_point so I think we should pick one of them. is_vector is needed anyway and one remaining issue here is whether is_vector should call is_tangent_vector or the other way round. I think it will be extremely rare to overload is_vector (or zero_vector) for manifolds, for vector spaces other than the tangent space.

@kellertuer
Copy link
Member

OK. I think we don't need both is_manifold_point and is_point so I think we should pick one of them. is_vector is needed anyway and one remaining issue here is whether is_vector should call is_tangent_vector or the other way round. I think it will be extremely rare to overload is_vector (or zero_vector) for manifolds, for vector spaces other than the tangent space.

We overload/define zero(_tangent)_vector! quite often, I think; will that get obsolete, so will there be a good default?

So, I think if we drop backwards compatibility, then we should get rid of is_tangent_vector and is_manifold_point and just use is_point and is_vector, though both names are not completely self-descriptive (you have to have in mind point->manifold, vector->tangent space or any other fibre).

@mateuszbaran
Copy link
Member Author

We overload/define zero(_tangent)_vector! quite often, I think; will that get obsolete, so will there be a good default?

Yes, we have some overloads for tangent vectors. What I mean is that for any other fibre there would usually be decent defaults. For tangent vectors it won't be obsolete.

So, I think if we drop backwards compatibility, then we should get rid of is_tangent_vector and is_manifold_point and just use is_point and is_vector, though both names are not completely self-descriptive (you have to have in mind point->manifold, vector->tangent space or any other fibre).

This patch already breaks quite a bit so I wouldn't worry about backwards compatibility. I'll get rid of is_tangent_vector and is_manifold_point then.

@kellertuer
Copy link
Member

Ok, let's just make sure, that @sethaxen at some point agrees, too; but I imagine he is also quite busy currently.

@sethaxen
Copy link
Member

Sorry, there's a lot of discussion here. Can someone summarize the current proposal/disagreement?

@kellertuer
Copy link
Member

I try to do summarise in order of renaming, since that was a trail of thoughts all this followed. The first is function names

  1. zero_tangent_vector is renamed to zero_vector for consistency with Julia
  2. is_tangent_vector is renamed to is_vector for consistency with 1.

Here my criticism is, that now the function name bears a little less information about what the function is doing, but if you have the full signature is_vector(M, p, X) it's fine. Even more these functions can now be used for any fibres – for the first maybe with an optional parameter, for the second depending on the type of X. So especially for co tangent vectors, these also should work.

  1. is_manifold_point is renamed to is_point since that is then consistent with 2. – for both one now needs the implicit knowledge either that points are on manifolds and vectors are in tangent spaces or the full signature is_point(M,p). For this I am ok, since I think I Walt to move to using p ∈ M anyways

Then we came across types

  1. MPoint is renamed to AbstractManifoldPoint, since that is more informative and the Abstract is more consistent with the rest of our naming scheme
  2. TVector and CoTVector get an abstract super type AbstractFibreVector, and while I writing this summary, we should actually call them AbstractTangentVector and AbstractCoTangentVector, respectively.

Finally since it is breaking everything anyways already here

  1. Manifold is renamed to AbstractManifold to be more consistent.

4.-6. were actually names I introduced, I think, when I started Manopt.jl and when I was not completely aware of the Julia naming scheme, so I think, since this is breaking anyways and renames a lot, this is a good time to introduce this consistency.

That‘s the proposal and I think currently there is no disagreement really – I think there is a small tradeoff, that is_vector bears a little too less information (without the rest of the signature), but it is good that it then can be used on arbitrary fibers.

But for sure, we would like to know your opinion, too.

@mateuszbaran
Copy link
Member Author

That's a good summary 🙂 . I'd just add that I want to do some generalization here for arbitrary fibers because PR JuliaManifolds/Manifolds.jl#325 finally makes it possible to handle them well.

@kellertuer
Copy link
Member

I just noticed, since we are renaming everything to shorten names, what about changing check_base_point to check_point (and document that a little better in check_tangent_vector. What do you think?

@mateuszbaran
Copy link
Member Author

Sure, that would be consistent with the other changes.

@mateuszbaran
Copy link
Member Author

I've formatted code locally using JuliaFormatter 0.13.10. Here JuliaFormatter 0.14 was used and it crashed on parsing our files 😕 .

@kellertuer
Copy link
Member

don‘t we have check_base mentioned here somewhere? I think at least is_vector (or check vector) should mention it in its doctoring. I will investigate the Julia<formatter issue tomorrow (can reproduce it even on master locally here).

@mateuszbaran
Copy link
Member Author

I've submitted an issue: domluna/JuliaFormatter.jl#410 .

@mateuszbaran
Copy link
Member Author

What do you mean by check_base?

@kellertuer
Copy link
Member

Cool, thanks for submitting that.

Ah yes, I mean check_base_pointwhich we might want to call check_point? That should be mentioned maybe in both doc strings even.

@mateuszbaran
Copy link
Member Author

OK, I see, that check_base_point. I think check_base_point is still fine? A little verbosity there doesn't look bad and the name is still correct.

@kellertuer
Copy link
Member

Ok, we can also leave it, it would still be good to mention it in the docs I think.

@mateuszbaran
Copy link
Member Author

I'm also thinking that we probably should just implement something like _check_vector for each manifold, and do something like

function check_vector(M::Manifold, p, X; check_base_point=true, kwargs...)
    if check_base_point
        mpe = check_point(M, p; kwargs...)
        mpe === nothing || return mpe
    end
    return _check_vector(M, p, X; kwargs...)
end

so that check_vector wouldn't have to duplicate the logic for checking the base point for each manifold.

@kellertuer
Copy link
Member

Maybe the easier solution is to only have check_base(_point) for is_vecor (i.e. the high level interface) and not for check_*(i.e. the lower one)?

@mateuszbaran
Copy link
Member Author

Yes, that's a good idea. I'll do that.

@kellertuer
Copy link
Member

Cool, one can see on Manifolds.jl how much redundancy this removes; great!

@mateuszbaran mateuszbaran merged commit 4956e72 into master May 19, 2021
@kellertuer kellertuer deleted the mbaran/bases-of-vector-spaces branch November 1, 2022 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants