Skip to content

Commit

Permalink
Merge branch 'master' into kellertuer/modularize-tests-I
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Sep 29, 2023
2 parents ef5a957 + 71cd2aa commit 2077027
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 60 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/nightly.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Manifolds"
uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
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.8.77"
version = "0.8.79"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down Expand Up @@ -51,7 +51,7 @@ Graphs = "1.4"
HybridArrays = "0.4"
Kronecker = "0.4, 0.5"
ManifoldDiff = "0.3.6"
ManifoldsBase = "0.14.11"
ManifoldsBase = "0.14.12"
MatrixEquations = "2.2"
OrdinaryDiffEq = "6.31"
Plots = "1"
Expand Down
3 changes: 2 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ BoundaryValueDiffEq = "4"
CondaPkg = "0.2"
DiffEqCallbacks = "2"
Distributions = "0.22.6, 0.23, 0.24, 0.25"
Documenter = "0.27"
Documenter = "1"
DocumenterCitations = "1.2.1"
FiniteDifferences = "0.12"
Graphs = "1.4"
HybridArrays = "0.4"
Expand Down
10 changes: 7 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ end

# (e) ...finally! make docs
bib = CitationBibliography(joinpath(@__DIR__, "src", "references.bib"); style=:alpha)
makedocs(
bib;
makedocs(;
# for development, we disable prettyurls
format=Documenter.HTML(prettyurls=false, assets=["assets/favicon.ico"]),
format=Documenter.HTML(
prettyurls=false,
assets=["assets/favicon.ico", "assets/citations.css"],
),
modules=[
Manifolds,
isdefined(Base, :get_extension) ?
Expand Down Expand Up @@ -165,5 +167,7 @@ makedocs(
"References" => "misc/references.md",
],
],
plugins=[bib],
warnonly=[:missing_docs],
)
deploydocs(repo="github.com/JuliaManifolds/Manifolds.jl.git", push_preview=true)
19 changes: 19 additions & 0 deletions docs/src/assets/citations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Taken from https://juliadocs.org/DocumenterCitations.jl/v1.2/styling/ */

.citation dl {
display: grid;
grid-template-columns: max-content auto; }
.citation dt {
grid-column-start: 1; }
.citation dd {
grid-column-start: 2;
margin-bottom: 0.75em; }
.citation ul {
padding: 0 0 2.25em 0;
margin: 0;
list-style: none;}
.citation ul li {
text-indent: -2.25em;
margin: 0.33em 0.5em 0.5em 2.25em;}
.citation ol li {
padding-left:0.75em;}
38 changes: 12 additions & 26 deletions src/manifolds/FixedRankMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ function allocate_result(
# vals are p and X, so we can use their fields to set up those of the UMVTVector
return UMVTVector(allocate(p.U, m, k), allocate(p.S, k, k), allocate(p.Vt, k, n))
end
function allocate_result(::FixedRankMatrices{m,n,k}, ::typeof(rand), p) where {m,n,k}
# vals are p and X, so we can use their fields to set up those of the UMVTVector
return UMVTVector(allocate(p.U, m, k), allocate(p.S, k, k), allocate(p.Vt, k, n))
end
function allocate_result(::FixedRankMatrices{m,n,k}, ::typeof(rand)) where {m,n,k}
return SVDMPoint(
Matrix{Float64}(undef, m, k),
Vector{Float64}(undef, k),
Matrix{Float64}(undef, k, n),
)
end

Base.copy(v::UMVTVector) = UMVTVector(copy(v.U), copy(v.M), copy(v.Vt))

Expand Down Expand Up @@ -448,32 +459,7 @@ and the singular values are sampled uniformly at random.
If `vector_at` is not `nothing`, generate a random tangent vector in the tangent space of
the point `vector_at` on the `FixedRankMatrices` manifold `M`.
"""
function Random.rand(M::FixedRankMatrices; vector_at=nothing, kwargs...)
return rand(Random.default_rng(), M; vector_at=vector_at, kwargs...)
end
function Random.rand(
rng::AbstractRNG,
M::FixedRankMatrices{m,n,k};
vector_at=nothing,
kwargs...,
) where {m,n,k}
if vector_at === nothing
p = SVDMPoint(
Matrix{Float64}(undef, m, k),
Vector{Float64}(undef, k),
Matrix{Float64}(undef, k, n),
)
return rand!(rng, M, p; kwargs...)
else
X = UMVTVector(
Matrix{Float64}(undef, m, k),
Matrix{Float64}(undef, k, k),
Matrix{Float64}(undef, k, n),
)
return rand!(rng, M, X; vector_at, kwargs...)
end
end

Random.rand(M::FixedRankMatrices; vector_at=nothing, kwargs...)
function Random.rand!(
rng::AbstractRNG,
::FixedRankMatrices{m,n,k},
Expand Down
2 changes: 1 addition & 1 deletion src/manifolds/GeneralUnitaryMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ end
Compute volume density function of a sphere, i.e. determinant of the differential of
exponential map `exp(M, p, X)`. It is derived from Eq. (4.1) and Corollary 4.4
in [ChevallierLiLuDunson:2022](@ref). See also Theorem 4.1 in [FalorsideHaanDavidsonForre:2019](@cite),
in [ChevallierLiLuDunson:2022](@cite). See also Theorem 4.1 in [FalorsideHaanDavidsonForre:2019](@cite),
(note that it uses a different convention).
"""
function volume_density(M::GeneralUnitaryMatrices{n,ℝ}, p, X) where {n}
Expand Down
13 changes: 13 additions & 0 deletions src/manifolds/PositiveNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ function parallel_transport_to!(::PositiveNumbers, Y, p, X, q)
return (Y .= X .* q ./ p)
end

function Random.rand(M::PositiveNumbers; kwargs...)
return rand(Random.default_rng(), M; kwargs...)
end

function Random.rand(rng::AbstractRNG, ::PositiveNumbers; σ=1.0, vector_at=nothing)
if vector_at === nothing
pX = exp(randn(rng) * σ)
else
pX = vector_at * randn(rng) * σ
end
return pX
end

function Random.rand!(
rng::AbstractRNG,
::PositiveNumbers,
Expand Down
4 changes: 4 additions & 0 deletions src/manifolds/SymmetricPositiveDefinite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ Generate a random symmetric positive definite matrix on the
"""
rand(M::SymmetricPositiveDefinite; σ::Real=1)

function allocate_result(M::SymmetricPositiveDefinite, ::typeof(Random.rand), p::SPDPoint)
return zero_vector(M, p)
end

function Random.rand!(
rng::AbstractRNG,
M::SymmetricPositiveDefinite{N},
Expand Down
4 changes: 4 additions & 0 deletions src/manifolds/VectorBundle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ See also [`VectorBundleInverseProductRetraction`](@ref).
"""
struct VectorBundleProductRetraction <: AbstractRetractionMethod end

function allocate_result(M::TangentSpaceAtPoint, ::typeof(rand))
return zero_vector(M.fiber.manifold, M.point)
end

base_manifold(B::VectorBundleFibers) = base_manifold(B.manifold)
base_manifold(B::VectorSpaceAtPoint) = base_manifold(B.fiber)
base_manifold(B::VectorBundle) = base_manifold(B.manifold)
Expand Down
8 changes: 8 additions & 0 deletions test/manifolds/positive_numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ include("../utils.jl")
@test volume_density(M, 0.5, 2.0) exp(4.0)
@test volume_density(M5, [0.5, 1.0, 2.0], [1.0, -1.0, 2.0]) exp(2.0)
end
@testset "Inplace random values" begin
p = fill(NaN)
X = fill(NaN)
rand!(M, p)
@test is_point(M, p)
rand!(M, X; vector_at=p)
@test is_vector(M, p, X)
end
end

0 comments on commit 2077027

Please sign in to comment.