Skip to content

Commit

Permalink
Merge pull request #32 from JuliaManifolds/parametrize-manifold
Browse files Browse the repository at this point in the history
* Parametrize Manifold by number field
* Rename `ArrayManifold` to `ValidationManifold`
  • Loading branch information
kellertuer authored Apr 1, 2020
2 parents 6b7656d + 5b8d628 commit 039807b
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 234 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.7.3"
version = "0.8.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ This way a manifold can benefit from existing implementations.
One example is the `TransparentIsometricEmbeddingType` where a manifold uses the metric,
`inner`, from its embedding.

## `ArrayManifold`
## `ValidationManifold`

The `ArrayManifold` further illustrates how one can also used types to
The `ValidationManifold` further illustrates how one can also used types to
represent points on a manifold, tangent vectors, and cotangent vectors,
where values are encapsulated in a certain type.

In general, `ArrayManifold` might be used for manifolds where these three types are represented
In general, `ValidationManifold` might be used for manifolds where these three types are represented
by more complicated data structures or when it is necessary to distinguish these
by type.

This adds a semantic layer to the interface, and the default implementation of
`ArrayManifold` adds checks to all inputs and outputs of typed data.
`ValidationManifold` adds checks to all inputs and outputs of typed data.
6 changes: 3 additions & 3 deletions src/DecoratorManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ end
# Type
#
"""
AbstractDecoratorManifold <: Manifold
AbstractDecoratorManifold{𝔽} <: Manifold{𝔽}
An `AbstractDecoratorManifold` indicates that to some extent a manifold subtype
decorates another manifold in the sense that it either
decorates another [`Manifold`](@ref) in the sense that it either
* it extends the functionality of a manifold with further features
* it defines a new manifold that internally uses functions from the decorated manifold
Expand All @@ -99,7 +99,7 @@ Transparency of functions with respect to decorators can be specified using the
[`@decorator_transparent_fallback`](@ref), [`@decorator_transparent_function`](@ref) and
[`@decorator_transparent_signature`](@ref).
"""
abstract type AbstractDecoratorManifold <: Manifold end
abstract type AbstractDecoratorManifold{𝔽} <: Manifold{𝔽} end

#
# Macros
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This manifold further illustrates how to type your manifold points and tangent v
that the interface does not require this, but it might be handy in debugging and educative
situations to verify correctness of involved variabes.
"""
struct DefaultManifold{T<:Tuple, 𝔽} <: Manifold where {T, 𝔽} end
struct DefaultManifold{T<:Tuple, 𝔽} <: Manifold{𝔽} end
DefaultManifold(n::Vararg{Int,N}; field = ℝ) where {N} = DefaultManifold{Tuple{n...}, field}()

function check_manifold_point(M::DefaultManifold, p; kwargs...)
Expand Down
106 changes: 56 additions & 50 deletions src/EmbeddedManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A type used to specify properties of an [`AbstractEmbeddedManifold`](@ref).
abstract type AbstractEmbeddingType end

"""
AbstractEmbeddedManifold{T<:AbstractEmbeddingType} <: AbstractDecoratorManifold
AbstractEmbeddedManifold{T<:AbstractEmbeddingType,𝔽} <: AbstractDecoratorManifold{𝔽}
An abstract type for embedded manifolds, which acts as an [`AbstractDecoratorManifold`](@ref).
The functions of the manifold that is embedded can hence be just passed on to the embedding.
Expand All @@ -16,8 +16,8 @@ This means, that technically an embedded manifold is a decorator for the embeddi
functions of this type get, in the semi-transparent way of the
[`AbstractDecoratorManifold`](@ref), passed on to the embedding.
"""
abstract type AbstractEmbeddedManifold{T<:AbstractEmbeddingType} <:
AbstractDecoratorManifold end
abstract type AbstractEmbeddedManifold{𝔽,T<:AbstractEmbeddingType} <:
AbstractDecoratorManifold{𝔽} end

"""
DefaultEmbeddingType <: AbstractEmbeddingType
Expand Down Expand Up @@ -57,7 +57,7 @@ and logarithmic maps.
struct TransparentIsometricEmbedding <: AbstractIsometricEmbeddingType end

"""
EmbeddedManifold{MT <: Manifold, NT <: Manifold, ET} <: AbstractEmbeddedManifold{ET}
EmbeddedManifold{𝔽, MT <: Manifold, NT <: Manifold, ET} <: AbstractEmbeddedManifold{𝔽, ET}
A type to represent that a [`Manifold`](@ref) `M` of type `MT` is indeed an emebedded
manifold and embedded into the manifold `N` of type `NT`.
Expand All @@ -77,16 +77,16 @@ Generate the `EmbeddedManifold` of the [`Manifold`](@ref) `M` into the
[`Manifold`](@ref) `N` with [`AbstractEmbeddingType`](@ref) `e` that by default is the most
transparent [`TransparentIsometricEmbedding`](@ref)
"""
struct EmbeddedManifold{MT<:Manifold,NT<:Manifold,ET} <: AbstractEmbeddedManifold{ET}
struct EmbeddedManifold{𝔽,MT<:Manifold{𝔽},NT<:Manifold,ET} <: AbstractEmbeddedManifold{𝔽,ET}
manifold::MT
embedding::NT
end
function EmbeddedManifold(
M::MT,
N::NT,
e::ET = TransparentIsometricEmbedding(),
) where {MT<:Manifold,NT<:Manifold,ET<:AbstractEmbeddingType}
return EmbeddedManifold{MT,NT,ET}(M, N)
) where {𝔽,MT<:Manifold{𝔽}, NT<:Manifold,ET<:AbstractEmbeddingType}
return EmbeddedManifold{𝔽,MT,NT,ET}(M, N)
end

"""
Expand Down Expand Up @@ -131,7 +131,13 @@ end
check that `embed(M,p,X)` is a valid tangent to `embed(p,X)`, where `check_base_point`
determines whether the validity of `p` is checked, too.
"""
function check_tangent_vector(M::AbstractEmbeddedManifold, p, X; check_base_point = true, kwargs...)
function check_tangent_vector(
M::AbstractEmbeddedManifold,
p,
X;
check_base_point = true,
kwargs...,
)
if check_base_point
mpe = check_manifold_point(M, p; kwargs...)
mpe === nothing || return mpe
Expand Down Expand Up @@ -164,8 +170,8 @@ end

function show(
io::IO,
M::EmbeddedManifold{MT,NT,ET},
) where {MT<:Manifold,NT<:Manifold,ET<:AbstractEmbeddingType}
M::EmbeddedManifold{𝔽,MT,NT,ET},
) where {𝔽, MT<:Manifold{𝔽},NT<:Manifold,ET<:AbstractEmbeddingType}
print(io, "EmbeddedManifold($(M.manifold), $(M.embedding), $(ET()))")
end

Expand Down Expand Up @@ -221,9 +227,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(exp),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -235,9 +241,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(exp!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand Down Expand Up @@ -284,9 +290,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(inner),
::AbstractEmbeddedManifold{<:AbstractIsometricEmbeddingType},
::AbstractEmbeddedManifold{𝔽,<:AbstractIsometricEmbeddingType},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -298,9 +304,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(inverse_retract),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -312,16 +318,16 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(inverse_retract!),
::AbstractEmbeddedManifold{<:AbstractIsometricEmbeddingType},
::AbstractEmbeddedManifold{𝔽,<:AbstractIsometricEmbeddingType},
args...,
)
) where {𝔽}
return Val(:parent)
end
function decorator_transparent_dispatch(
::typeof(inverse_retract!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end

Expand All @@ -334,9 +340,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(log),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -348,19 +354,19 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(log!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(::typeof(norm), ::AbstractEmbeddedManifold, args...)
return Val(:intransparent)
end
function decorator_transparent_dispatch(
::typeof(norm),
::AbstractEmbeddedManifold{<:AbstractIsometricEmbeddingType},
::AbstractEmbeddedManifold{𝔽,<:AbstractIsometricEmbeddingType},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -379,9 +385,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(project!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -393,9 +399,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(project),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -407,9 +413,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(retract),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -421,16 +427,16 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(retract!),
::AbstractEmbeddedManifold{<:AbstractIsometricEmbeddingType},
::AbstractEmbeddedManifold{𝔽,<:AbstractIsometricEmbeddingType},
args...,
)
) where {𝔽}
return Val(:parent)
end
function decorator_transparent_dispatch(
::typeof(retract!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -442,9 +448,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_along),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -456,9 +462,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_along!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -470,9 +476,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_direction),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -484,9 +490,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_direction!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -498,9 +504,9 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_to),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
function decorator_transparent_dispatch(
Expand All @@ -512,8 +518,8 @@ function decorator_transparent_dispatch(
end
function decorator_transparent_dispatch(
::typeof(vector_transport_to!),
::AbstractEmbeddedManifold{<:TransparentIsometricEmbedding},
::AbstractEmbeddedManifold{𝔽,<:TransparentIsometricEmbedding},
args...,
)
) where {𝔽}
return Val(:transparent)
end
Loading

2 comments on commit 039807b

@kellertuer
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/11960

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.8.0 -m "<description of version>" 039807bff9a132dbfeabb638bf769661d36afebe
git push origin v0.8.0

Please sign in to comment.