Skip to content

Commit

Permalink
Fix allocation on nested power manifold (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran authored Mar 16, 2023
1 parent 60ac8f6 commit 57abbeb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
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 <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.14.2"
version = "0.14.3"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
16 changes: 14 additions & 2 deletions src/PowerManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,25 @@ function Base.:^(
return PowerManifold(M, size...)
end

"""
_allocate_access_nested(M::PowerManifoldNested, y, i)
Helper function for `allocate_result` on `PowerManifoldNested`. In allocation `y` can be
a number in which case `_access_nested` wouldn't work.
"""
_allocate_access_nested(M::PowerManifoldNested, y, i) = _access_nested(M, y, i)
_allocate_access_nested(::PowerManifoldNested, y::Number, i) = y

function allocate_result(M::PowerManifoldNested, f, x...)
if representation_size(M.manifold) === () && length(x) > 0
return allocate(M, x[1])
else
return [
allocate_result(M.manifold, f, map(y -> _access_nested(M, y, i), x)...) for
i in get_iterator(M)
allocate_result(
M.manifold,
f,
map(y -> _allocate_access_nested(M, y, i), x)...,
) for i in get_iterator(M)
]
end
end
Expand Down
1 change: 1 addition & 0 deletions test/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct TestArrayRepresentation <: AbstractPowerRepresentation end
@testset "specific functions" begin
@test distance(N, p, q) == sqrt(sum(distance.(Ref(M), p, q) .^ 2))
@test exp(N, p, q) == p .+ q
@test exp(N, p, q, 2) == p .+ 2 .* q

@test retract(N, p, q) == p .+ q
@test retract(N, p, q, ExponentialRetraction()) == p .+ q
Expand Down

2 comments on commit 57abbeb

@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
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/79742

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.14.3 -m "<description of version>" 57abbeb5da0a5c4ad1857a9896d0bec5770a6623
git push origin v0.14.3

Please sign in to comment.