Skip to content

Commit

Permalink
Make vee and hat always use real coefficient basis (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran authored Nov 8, 2023
1 parent eebe99d commit 4332265
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
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.15.2] 8/11/2023

### Fixed

- `vee` and `hat` now use real coefficient basis for complex manifolds.

## [0.15.1] 30/10/2023

### 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 = "ManifoldsBase"
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
authors = ["Seth Axen <seth.axen@gmail.com>", "Mateusz Baran <mateuszbaran89@gmail.com>", "Ronny Bergmann <manopt@ronnybergmann.net>", "Antoine Levitt <antoine.levitt@gmail.com>"]
version = "0.15.1"
version = "0.15.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
29 changes: 17 additions & 12 deletions src/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ GramSchmidtOrthonormalBasis(𝔽::AbstractNumbers = ℝ) = GramSchmidtOrthonorma
An orthonormal basis `Ξ` as a vector of tangent vectors (of length determined by
[`manifold_dimension`](@ref)) in the tangent space that diagonalizes the curvature
tensor $R(u,v)w$ and where the direction `frame_direction` $v$ has curvature `0`.
tensor ``R(u,v)w`` and where the direction `frame_direction` ``v`` has curvature `0`.
The type parameter `𝔽` denotes the [`AbstractNumbers`](@ref) that will be used
for the vectors elements.
Expand Down Expand Up @@ -373,8 +373,8 @@ end
Get the dual basis to `B`, a basis of a vector space at point `p` from manifold `M`.
The dual to the $i$th vector $v_i$ from basis `B` is a vector $v^i$ from the dual space
such that $v^i(v_j) = δ^i_j$, where $δ^i_j$ is the Kronecker delta symbol:
The dual to the ``i``th vector ``v_i`` from basis `B` is a vector ``v^i`` from the dual space
such that ``v^i(v_j) = δ^i_j``, where ``δ^i_j`` is the Kronecker delta symbol:
````math
δ^i_j = \begin{cases}
1 & \text{ if } i=j, \\
Expand Down Expand Up @@ -920,9 +920,9 @@ end
@doc raw"""
hat(M::AbstractManifold, p, Xⁱ)
Given a basis $e_i$ on the tangent space at a point `p` and tangent
component vector $X^i$, compute the equivalent vector representation
$X=X^i e_i$, where Einstein summation notation is used:
Given a basis ``e_i`` on the tangent space at a point `p` and tangent
component vector ``X^i ∈ ℝ``, compute the equivalent vector representation
``X=X^i e_i``, where Einstein summation notation is used:
````math
∧ : X^i ↦ X^i e_i
Expand All @@ -932,8 +932,10 @@ For array manifolds, this converts a vector representation of the tangent
vector to an array representation. The [`vee`](@ref) map is the `hat` map's
inverse.
"""
@inline hat(M::AbstractManifold, p, X) = get_vector(M, p, X, VeeOrthogonalBasis())
@inline hat!(M::AbstractManifold, Y, p, X) = get_vector!(M, Y, p, X, VeeOrthogonalBasis())
@inline hat(M::AbstractManifold, p, X) =
get_vector(M, p, X, VeeOrthogonalBasis(number_system(M)))
@inline hat!(M::AbstractManifold, Y, p, X) =
get_vector!(M, Y, p, X, VeeOrthogonalBasis(number_system(M)))

"""
number_of_coordinates(M::AbstractManifold{𝔽}, B::AbstractBasis)
Expand Down Expand Up @@ -1063,8 +1065,8 @@ end
@doc raw"""
vee(M::AbstractManifold, p, X)
Given a basis $e_i$ on the tangent space at a point `p` and tangent
vector `X`, compute the vector components $X^i$, such that $X = X^i e_i$, where
Given a basis ``e_i`` on the tangent space at a point `p` and tangent
vector `X`, compute the vector components ``X^i ∈ ℝ``, such that ``X = X^i e_i``, where
Einstein summation notation is used:
````math
Expand All @@ -1075,5 +1077,8 @@ For array manifolds, this converts an array representation of the tangent
vector to a vector representation. The [`hat`](@ref) map is the `vee` map's
inverse.
"""
vee(M::AbstractManifold, p, X) = get_coordinates(M, p, X, VeeOrthogonalBasis())
vee!(M::AbstractManifold, Y, p, X) = get_coordinates!(M, Y, p, X, VeeOrthogonalBasis())
vee(M::AbstractManifold, p, X) =
get_coordinates(M, p, X, VeeOrthogonalBasis(number_system(M)))
function vee!(M::AbstractManifold, Y, p, X)
return get_coordinates!(M, Y, p, X, VeeOrthogonalBasis(number_system(M)))
end
7 changes: 7 additions & 0 deletions test/default_manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -880,4 +880,11 @@ Base.size(x::MatrixVectorTransport) = (size(x.m, 2),)
@test repr(MS) == "DefaultManifold(3; field = ℝ, parameter = :type)"
@test_throws ArgumentError ManifoldsBase.DefaultManifold(3; parameter = :foo)
end

@testset "complex vee and hat" begin
MC = ManifoldsBase.DefaultManifold(3; field = ManifoldsBase.ℂ)
p = [1im, 2 + 2im, 3.0]
@test isapprox(vee(MC, p, [1 + 2im, 3 + 4im, 5 + 6im]), [1, 3, 5, 2, 4, 6])
@test isapprox(hat(MC, p, [1, 3, 5, 2, 4, 6]), [1 + 2im, 3 + 4im, 5 + 6im])
end
end

2 comments on commit 4332265

@mateuszbaran
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register

Release notes:

Fixed

  • vee and hat now use real coefficient basis for complex manifolds.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/95010

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.2 -m "<description of version>" 43322654ab45a16e05ffa4103adeb8256d519811
git push origin v0.15.2

Please sign in to comment.