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

Fixes a bug, that occured when calling exp!(Rotations(2), p, p, X) since q=p was modified. #392

Merged
merged 5 commits into from
Jun 25, 2021

Conversation

kellertuer
Copy link
Member

So the exp! returned a wrong result when called as exp!(M, p, p X) due to this side effect. Also adds a test for this.

Copy link
Member

@mateuszbaran mateuszbaran left a comment

Choose a reason for hiding this comment

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

Actually, this may be a way more common problem. IIRC many mutating operations assume that there is no memory aliasing between output and input arguments. We may need to check it more thoroughly (including tests in general manifold testing).

test/rotations.jl Outdated Show resolved Hide resolved
src/manifolds/Rotations.jl Outdated Show resolved Hide resolved
kellertuer and others added 2 commits June 25, 2021 13:01
Co-authored-by: Mateusz Baran <[email protected]>
@@ -62,6 +62,12 @@ include("utils.jl")
v = log(M, pts[1], pts[2])
@test norm(M, pts[1], v) ≈ (angles[2] - angles[1]) * sqrt(2)

# check that exp! does not have a side effect
q = copy(M, pts[1])
Copy link
Member

Choose a reason for hiding this comment

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

We could actually move this test to general manifold tests. It is something Manopt.jl assumes so checking it for all manifolds makes sense IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Manopt.jl would be maybe a little generic, actually I always assumed that that is the case ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Since you also opened an Issue for the generic case, maybe let‘s solve it in a generic separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

OK, sure, I'll try that in a separate PR in the evening today or tomorrow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, we do not have the copy you proposed to use.

Copy link
Member

Choose a reason for hiding this comment

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

Weird, I think we should have that copy.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, we should, since we have copyto!, but maybe lets do a new PR (even in ManifoldsBase?) it would just combining existing methods.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, it's an issue for ManifoldsBase.jl.

I might have mixed up row- and column major indexing and hence have introduced the rotation the wrong direction around.
fix allocation of `q`.
@codecov
Copy link

codecov bot commented Jun 25, 2021

Codecov Report

Merging #392 (2d5ce6e) into master (8a5d654) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #392      +/-   ##
==========================================
- Coverage   97.92%   97.92%   -0.01%     
==========================================
  Files          76       76              
  Lines        5919     5914       -5     
==========================================
- Hits         5796     5791       -5     
  Misses        123      123              
Impacted Files Coverage Δ
src/manifolds/Rotations.jl 95.83% <100.00%> (-0.09%) ⬇️

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 8a5d654...2d5ce6e. Read the comment docs.

@kellertuer kellertuer merged commit 991569f into master Jun 25, 2021
@kellertuer kellertuer deleted the fixRot2 branch June 27, 2021 08:19
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.

2 participants