Skip to content

Commit

Permalink
Some issues with allocation on complex manifolds
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Nov 7, 2023
1 parent 848f618 commit e0b2323
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 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.9.5] - 2023-11-dd

### Changed

- `identity_element` now returns a complex matrix for unitary group.

## [0.9.4] - 2023-11-06

### Added
Expand Down
8 changes: 8 additions & 0 deletions src/groups/general_unitary_groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ function allocate_result(M::Rotations, ::typeof(rand), ::Identity{Multiplication
return similar(Matrix{Float64}, representation_size(M)...)
end

function allocation_promotion_function(

Check warning on line 48 in src/groups/general_unitary_groups.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/general_unitary_groups.jl#L48

Added line #L48 was not covered by tests
::GeneralUnitaryMultiplicationGroup{<:Any,ℂ},
::typeof(identity_element),
args::Tuple,
)
return complex

Check warning on line 53 in src/groups/general_unitary_groups.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/general_unitary_groups.jl#L53

Added line #L53 was not covered by tests
end

decorated_manifold(G::GeneralUnitaryMultiplicationGroup) = G.manifold

@doc raw"""
Expand Down
5 changes: 3 additions & 2 deletions src/groups/group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ end

@trait_function identity_element!(G::AbstractDecoratorManifold, p)

function allocate_result(G::AbstractDecoratorManifold, ::typeof(identity_element))
return zeros(representation_size(G)...)
function allocate_result(G::AbstractDecoratorManifold, f::typeof(identity_element))
apf = allocation_promotion_function(G, f, ())
return zeros(apf(Float64), representation_size(G)...)

Check warning on line 249 in src/groups/group.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group.jl#L247-L249

Added lines #L247 - L249 were not covered by tests
end

@doc raw"""
Expand Down
2 changes: 2 additions & 0 deletions test/groups/general_unitary_groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ include("group_utils.jl")
@test manifold_volume(Unitary(3)) sqrt(3) * 2 * π^6
@test manifold_volume(Unitary(4)) sqrt(2) * 8 * π^10 / 12

@test identity_element(U2) isa Matrix{ComplexF64}

for n in [1, 2, 3]
Un = Unitary(n)
X = zeros(ComplexF64, n, n)
Expand Down

0 comments on commit e0b2323

Please sign in to comment.