diff --git a/Project.toml b/Project.toml index c9f15b84..33e92c23 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ManifoldsBase" uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb" authors = ["Seth Axen ", "Mateusz Baran ", "Ronny Bergmann ", "Antoine Levitt "] -version = "0.14.11" +version = "0.14.12" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/ManifoldsBase.jl b/src/ManifoldsBase.jl index d3d6e6c1..9296f1fc 100644 --- a/src/ManifoldsBase.jl +++ b/src/ManifoldsBase.jl @@ -854,21 +854,30 @@ Optionally a random number generator `rng` to be used can be specified. An optio """ Random.rand(M::AbstractManifold) + function Random.rand(M::AbstractManifold, d::Integer; kwargs...) return [rand(M; kwargs...) for _ in 1:d] end function Random.rand(rng::AbstractRNG, M::AbstractManifold, d::Integer; kwargs...) return [rand(rng, M; kwargs...) for _ in 1:d] end -function Random.rand(M::AbstractManifold; kwargs...) - p = allocate_result(M, rand) - rand!(M, p; kwargs...) - return p +function Random.rand(M::AbstractManifold; vector_at = nothing, kwargs...) + if vector_at === nothing + pX = allocate_result(M, rand) + else + pX = allocate_result(M, rand, vector_at) + end + rand!(M, pX; vector_at = vector_at, kwargs...) + return pX end -function Random.rand(rng::AbstractRNG, M::AbstractManifold; kwargs...) - p = allocate_result(M, rand) - rand!(rng, M, p; kwargs...) - return p +function Random.rand(rng::AbstractRNG, M::AbstractManifold; vector_at = nothing, kwargs...) + if vector_at === nothing + pX = allocate_result(M, rand) + else + pX = allocate_result(M, rand, vector_at) + end + rand!(rng, M, pX; vector_at = vector_at, kwargs...) + return pX end @doc raw"""