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

Some issues with allocation on complex manifolds #677

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

mateuszbaran
Copy link
Member

This should fix #668 . Now we have:

julia> G = Unitary(2)
Unitary(2)

julia> eltype(allocate_result(G, typeof(rand), identity_element(G)))
ComplexF64 (alias for Complex{Float64})

julia> allocate_result(G, typeof(rand))
2×2 Matrix{ComplexF64}:
 6.91456e-310+6.91456e-310im  6.91463e-310+6.91456e-310im
 6.91456e-310+6.91456e-310im  6.91456e-310+6.91457e-310im

@mateuszbaran mateuszbaran added the Ready-for-Review A label for pull requests that are feature-ready label Nov 7, 2023
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #677 (3d14c02) into master (848f618) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #677   +/-   ##
=======================================
  Coverage   99.57%   99.57%           
=======================================
  Files         108      108           
  Lines       10675    10678    +3     
=======================================
+ Hits        10630    10633    +3     
  Misses         45       45           
Files Coverage Δ
src/Manifolds.jl 86.66% <ø> (ø)
src/groups/general_unitary_groups.jl 100.00% <100.00%> (ø)
src/groups/group.jl 100.00% <100.00%> (ø)
src/groups/unitary.jl 100.00% <ø> (ø)
src/manifolds/GeneralUnitaryMatrices.jl 100.00% <ø> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@kellertuer
Copy link
Member

Ah, maybe check for code coverage as well (but it seems to still be running?)

@mateuszbaran
Copy link
Member Author

Coverage is fine now, the only issue is the randomly failing integration test but there I just hope it will resolve itself.

@mateuszbaran
Copy link
Member Author

I will also take a look at other complex Lie groups before merging this PR.

@Affie
Copy link
Contributor

Affie commented Nov 8, 2023

I will also take a look at other complex Lie groups before merging this PR.

While you are in this area, I've had issues with the unit quaternion group as well. It may have been finger trouble, but couldn’t get a lot of the functionality to work. For example get_coordinates and get_vector. We are using SO3 so not a blocker.

@mateuszbaran
Copy link
Member Author

What exactly doesn't work with unit quaternions? get_vector and get_coordinates might be a bit non-intuitive there because you need to indicate that you want real coefficients like here:

julia> using Manifolds

julia> using Quaternions

julia> p = QuaternionF64(
           0.4815296357756736,
           0.6041613272484806,
           -0.2322369798903669,
           0.5909181717450419,
       )
QuaternionF64(0.4815296357756736, 0.6041613272484806, -0.2322369798903669, 0.5909181717450419)

julia> get_coordinates(G, p, QuaternionF64(0, 1, 2, 3), DefaultOrthonormalBasis(ℍ))
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
 1.0
 2.0
 3.0

Note DefaultOrthonormalBasis(ℍ) instead of DefaultOrthonormalBasis(). I'm not sure this convention was the right decision but it doesn't seem worth a rework.

@mateuszbaran
Copy link
Member Author

I've taken a look at other groups and they don't seem to have similar issues. I've just made some cleanup while reading the code and exported number_of_coordinates. ManifoldsBase.jl already exports that function so I was surprised it's not exported here.

@mateuszbaran mateuszbaran added the preview docs Add this label if you want to see a PR-preview of the documentation label Nov 8, 2023
@Affie
Copy link
Contributor

Affie commented Nov 8, 2023

Thanks, so it was my mistake then. I missed the DefaultOrthonormalBasis(ℍ) . The error is related to allocations so thought it was related, vee and hat might be broken though.
ERROR: MethodError: no method matching similar(::QuaternionF64, ::Type{QuaternionF64}, ::Int64)

@kellertuer
Copy link
Member

vee and hat might be broken though. ERROR: MethodError: no method matching similar(::QuaternionF64, ::Type{QuaternionF64}, ::Int64)

Are you maybe accidentially entering this with integer numbers instead of floats?

@mateuszbaran
Copy link
Member Author

The problem with vee and hat is that they perhaps should pick the real-coefficient, basis. @kellertuer would you be fine with changing

vee(M::AbstractManifold, p, X) = get_coordinates(M, p, X, VeeOrthogonalBasis())

to

vee(M::AbstractManifold, p, X) = get_coordinates(M, p, X, VeeOrthogonalBasis(number_system(M))

?
It's technically breaking but makes them more useful IMO.

@kellertuer
Copy link
Member

I would even consider that a bug fix.

@mateuszbaran
Copy link
Member Author

Cool, I will make another PR then.

@mateuszbaran mateuszbaran merged commit 2104bef into master Nov 8, 2023
26 checks passed
@kellertuer kellertuer deleted the mbaran/fix-allocation-unitary branch May 4, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview docs Add this label if you want to see a PR-preview of the documentation Ready-for-Review A label for pull requests that are feature-ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible allocation issue with complex groups?
3 participants