Skip to content

Commit

Permalink
Improve performance of get_vector and get_coordinates in some cases o…
Browse files Browse the repository at this point in the history
…n complex Euclidean (#779)
  • Loading branch information
mateuszbaran authored Jan 10, 2025
1 parent 2b13e39 commit ca9e634
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ whitespace_in_kwargs = false
remove_extra_newlines = true
annotate_untyped_fields_with_any = false
conditional_to_if = false
ignore = ["tutorials"]
ignore = ["tutorials", ".git"]
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.12] - unreleased

### Changed

* Improved performance of selected `get_vector` and `get_coordinates` methods for complex `Euclidean` manifold.

## [0.10.11] - 2025-01-02

### Added
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Manifolds"
uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.10.11"
version = "0.10.12"

[deps]
Einsum = "b7d42ee7-0b51-5a75-98ca-779d3107e4c0"
Expand Down
32 changes: 15 additions & 17 deletions src/manifolds/Euclidean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,41 +251,39 @@ function get_coordinates_induced_basis!(
X,
::InducedBasis{ℝ,TangentSpaceType,<:RetractionAtlas},
)
S = representation_size(M)
PS = prod(S)
copyto!(c, reshape(X, PS))
copyto!(c, vec(X))
return c
end

function get_coordinates_orthonormal!(M::Euclidean{<:Any,ℂ}, c, ::Any, X, ::RealNumbers)
S = representation_size(M)
PS = prod(S)
c .= [reshape(real.(X), PS)..., reshape(imag(X), PS)...]
function get_coordinates_orthonormal!(::Euclidean{<:Any,ℂ}, c, ::Any, X, ::RealNumbers)
Xvec = vec(X)
d = div(length(c), 2)
view(c, 1:d) .= real.(Xvec)
view(c, (d + 1):(2d)) .= imag.(Xvec)
return c
end

function get_coordinates_diagonalizing!(
M::Euclidean{<:Any,ℂ},
::Euclidean{<:Any,ℂ},
c,
::Any,
X,
::DiagonalizingOrthonormalBasis{ℝ},
)
S = representation_size(M)
PS = prod(S)
c .= [reshape(real.(X), PS)..., reshape(imag(X), PS)...]
Xvec = vec(X)
d = div(length(c), 2)
view(c, 1:d) .= real.(Xvec)
view(c, (d + 1):(2d)) .= imag.(Xvec)
return c
end
function get_coordinates_diagonalizing!(
M::Euclidean{<:Any,𝔽},
::Euclidean{<:Any,𝔽},
c,
p,
X,
::DiagonalizingOrthonormalBasis{𝔽},
) where {𝔽}
S = representation_size(M)
PS = prod(S)
copyto!(c, reshape(X, PS))
copyto!(c, vec(X))
return c
end

Expand Down Expand Up @@ -377,7 +375,7 @@ end
function get_vector_orthonormal!(M::Euclidean{<:Any,ℂ}, Y, ::Any, c, ::RealNumbers)
S = representation_size(M)
N = div(length(c), 2)
copyto!(Y, reshape(c[1:N] + im * c[(N + 1):end], S))
copyto!(Y, reshape(c[1:N] .+ im .* c[(N + 1):end], S))
return Y
end
function get_vector_diagonalizing!(
Expand All @@ -389,7 +387,7 @@ function get_vector_diagonalizing!(
)
S = representation_size(M)
N = div(length(c), 2)
copyto!(Y, reshape(c[1:N] + im * c[(N + 1):end], S))
copyto!(Y, reshape(c[1:N] .+ im .* c[(N + 1):end], S))
return Y
end

Expand Down

0 comments on commit ca9e634

Please sign in to comment.