Skip to content

Commit ba4a2ff

Browse files
authored
fix tangent vector allocations (nearly) (#168)
* fix tangent vector allocations * Remove a method. * bump version.
1 parent b3d14c5 commit ba4a2ff

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ManifoldsBase"
22
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
33
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
4-
version = "0.14.11"
4+
version = "0.14.12"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/ManifoldsBase.jl

+17-8
Original file line numberDiff line numberDiff line change
@@ -854,21 +854,30 @@ Optionally a random number generator `rng` to be used can be specified. An optio
854854
855855
"""
856856
Random.rand(M::AbstractManifold)
857+
857858
function Random.rand(M::AbstractManifold, d::Integer; kwargs...)
858859
return [rand(M; kwargs...) for _ in 1:d]
859860
end
860861
function Random.rand(rng::AbstractRNG, M::AbstractManifold, d::Integer; kwargs...)
861862
return [rand(rng, M; kwargs...) for _ in 1:d]
862863
end
863-
function Random.rand(M::AbstractManifold; kwargs...)
864-
p = allocate_result(M, rand)
865-
rand!(M, p; kwargs...)
866-
return p
864+
function Random.rand(M::AbstractManifold; vector_at = nothing, kwargs...)
865+
if vector_at === nothing
866+
pX = allocate_result(M, rand)
867+
else
868+
pX = allocate_result(M, rand, vector_at)
869+
end
870+
rand!(M, pX; vector_at = vector_at, kwargs...)
871+
return pX
867872
end
868-
function Random.rand(rng::AbstractRNG, M::AbstractManifold; kwargs...)
869-
p = allocate_result(M, rand)
870-
rand!(rng, M, p; kwargs...)
871-
return p
873+
function Random.rand(rng::AbstractRNG, M::AbstractManifold; vector_at = nothing, kwargs...)
874+
if vector_at === nothing
875+
pX = allocate_result(M, rand)
876+
else
877+
pX = allocate_result(M, rand, vector_at)
878+
end
879+
rand!(rng, M, pX; vector_at = vector_at, kwargs...)
880+
return pX
872881
end
873882

874883
@doc raw"""

0 commit comments

Comments
 (0)