Skip to content

Commit c13b97e

Browse files
Introduce ZeroVector (#280)
* Move ZeroVector to tangent_space. * Test coverage; fix/remove arbitrary numbering in the comments. * add two two further cases. --------- Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
1 parent db44779 commit c13b97e

11 files changed

Lines changed: 141 additions & 331 deletions

File tree

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.5.0] 08/07/2026
9+
10+
## Added
11+
12+
* a `ZeroVector` type, to allow for static dispatch and avoid allocating unnecessary zeros similar to the [`Identity`](https://juliamanifolds.github.io/LieGroups.jl/stable/interface/operations/#LieGroups.Identity) on [`LieGroups.jl`](https://github.com/JuliaManifolds/LieGroups.jl).
13+
814
## [2.4.0] 03/06/2026
915

1016
### Added

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ManifoldsBase"
22
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
3-
version = "2.4.0"
3+
version = "2.5.0"
44
authors = ["Seth Axen <seth.axen@gmail.com>", "Mateusz Baran <mateuszbaran89@gmail.com>", "Ronny Bergmann <manopt@ronnybergmann.net>", "Antoine Levitt <antoine.levitt@gmail.com>"]
55

66
[workspace]

docs/src/manifolds.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ helpers to build or create manifolds based on existing manifolds
55

66
## A default manifold
77

8-
[`DefaultManifold`](@ref ManifoldsBase.DefaultManifold) is a simplified version of [`Euclidean`](https://juliamanifolds.github.io/Manifolds.jl/latest/manifolds/euclidean.html) and demonstrates a basic interface implementation.
8+
[`DefaultManifold`](@ref ManifoldsBase.DefaultManifold) is a simplified version of [`Euclidean`](@extref `Manifolds.Euclidean`) and demonstrates a basic interface implementation.
99
It can be used to perform simple tests.
10-
Since when using `Manifolds.jl` the [`Euclidean`](https://juliamanifolds.github.io/Manifolds.jl/latest/manifolds/euclidean.html) is available, the `DefaultManifold` itself is not exported.
10+
Since when using `Manifolds.jl` the [`Euclidean`](@extref `Manifolds.Euclidean`) is available, the [`DefaultManifold`](@ref ManifoldsBase.DefaultManifold) itself is not exported.
1111

1212
```@docs
1313
ManifoldsBase.DefaultManifold

src/ManifoldsBase.jl

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,9 @@
88
module ManifoldsBase
99

1010
import Base:
11-
isapprox,
12-
exp,
13-
log,
14-
convert,
15-
copy,
16-
copyto!,
17-
angle,
18-
eltype,
19-
fill,
20-
fill!,
21-
isempty,
22-
length,
23-
similar,
24-
show,
25-
+,
26-
-,
27-
*,
28-
==
11+
isapprox, exp, log,
12+
convert, copy, copyto!, angle, eltype, fill, fill!, isempty, length, similar, show,
13+
+, -, *, ==
2914
import LinearAlgebra: ×, dot, norm, det, cross, I, UniformScaling, Diagonal
3015
import Random: rand, rand!
3116

@@ -1229,6 +1214,7 @@ function zero_vector(M::AbstractManifold, p)
12291214
return X
12301215
end
12311216

1217+
12321218
#
12331219
#
12341220
# Internal function to set plotting backend
@@ -1266,6 +1252,7 @@ end
12661252
include("errors.jl")
12671253
include("parallel_transport.jl")
12681254
include("vector_transport.jl")
1255+
12691256
include("shooting.jl")
12701257
include("vector_spaces.jl")
12711258
include("point_vector_fallbacks.jl")
@@ -1332,13 +1319,10 @@ end
13321319
# Export
13331320
# ------
13341321
#
1335-
# (a) Manifolds and general types
1322+
# Manifolds and general types
13361323
export AbstractManifold,
1337-
AbstractManifoldPoint,
1338-
AbstractTangentVector,
1339-
AbstractCotangentVector,
1340-
TFVector,
1341-
CoTFVector
1324+
AbstractManifoldPoint, AbstractTangentVector, AbstractCotangentVector,
1325+
TFVector, CoTFVector, ZeroVector
13421326
export AbstractAffineConnection, ConnectionManifold, LeviCivitaConnection
13431327
export AbstractMetric, MetricManifold
13441328
export VectorSpaceFiber
@@ -1355,8 +1339,7 @@ export AbstractPowerRepresentation,
13551339
NestedPowerRepresentation, NestedReplacingPowerRepresentation
13561340
export ProductManifold
13571341

1358-
# (b) Generic Estimation Types
1359-
1342+
# Generic Estimation Types
13601343
export GeodesicInterpolationWithinRadius,
13611344
CyclicProximalPointEstimation,
13621345
ExtrinsicEstimation,
@@ -1365,8 +1348,7 @@ export GeodesicInterpolationWithinRadius,
13651348
AbstractApproximationMethod,
13661349
GeodesicInterpolation
13671350

1368-
1369-
# (b) Retraction Types
1351+
# Retraction Types
13701352
export AbstractRetractionMethod,
13711353
ApproximateRetraction,
13721354
ApproximateExponentialRetraction,
@@ -1385,7 +1367,7 @@ export AbstractRetractionMethod,
13851367
SoftmaxRetraction,
13861368
StabilizedRetraction
13871369

1388-
# (c) Inverse Retraction Types
1370+
# Inverse Retraction Types
13891371
export AbstractInverseRetractionMethod,
13901372
ApproximateInverseRetraction,
13911373
ApproximateLogarithmicInverseRetraction,
@@ -1402,7 +1384,7 @@ export AbstractInverseRetractionMethod,
14021384
SoftmaxInverseRetraction,
14031385
StabilizedInverseRetraction
14041386

1405-
# (d) Vector Transport Types
1387+
# Vector Transport Types
14061388
export AbstractVectorTransportMethod,
14071389
DifferentiatedRetractionVectorTransport,
14081390
EmbeddedVectorTransport,
@@ -1416,7 +1398,7 @@ export AbstractVectorTransportMethod,
14161398
VectorTransportTo,
14171399
VectorTransportWithKeywords
14181400

1419-
# (e) Basis Types
1401+
# Basis Types
14201402
export CachedBasis,
14211403
DefaultBasis,
14221404
DefaultOrthogonalBasis,
@@ -1427,12 +1409,12 @@ export CachedBasis,
14271409
ProjectedOrthonormalBasis,
14281410
VeeOrthogonalBasis
14291411

1430-
# (f) Error Messages
1412+
# Error Messages
14311413
export OutOfInjectivityRadiusError, ManifoldDomainError
14321414
export ApproximatelyError
14331415
export CompositeManifoldError, ComponentManifoldError, ManifoldDomainError
14341416

1435-
# (g) Functions on Manifolds
1417+
# Functions on Manifolds
14361418
export ×,
14371419
ℝ,
14381420
ℂ,

src/bases.jl

Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,14 @@ function allocate_coordinates(M::AbstractManifold, p::Int, T, n::Int)
298298
return (representation_size(M) == () && n == 0) ? zero(T) : zeros(T, n)
299299
end
300300
function allocate_result(
301-
M::AbstractManifold,
302-
f::typeof(get_coordinates),
303-
p,
304-
X,
305-
basis::AbstractBasis{𝔽},
301+
M::AbstractManifold, f::typeof(get_coordinates), p, X, basis::AbstractBasis{𝔽},
306302
) where {𝔽}
307303
T = coordinate_eltype(M, p, 𝔽)
308304
return allocate_coordinates(M, p, T, number_of_coordinates(M, basis))
309305
end
310306

311307
@inline function allocate_result_type(
312-
M::AbstractManifold,
313-
f::typeof(get_vector),
314-
args::Tuple{Any, Vararg{Any}},
308+
M::AbstractManifold, f::typeof(get_vector), args::Tuple{Any, Vararg{Any}},
315309
)
316310
apf = allocation_promotion_function(M, f, args)
317311
return apf(
@@ -369,12 +363,7 @@ function change_basis(M::AbstractManifold, p, c, B_in::AbstractBasis, B_out::Abs
369363
end
370364

371365
function change_basis!(
372-
M::AbstractManifold,
373-
c_out,
374-
p,
375-
c,
376-
B_in::AbstractBasis,
377-
B_out::AbstractBasis,
366+
M::AbstractManifold, c_out, p, c, B_in::AbstractBasis, B_out::AbstractBasis,
378367
)
379368
return get_coordinates!(M, c_out, p, get_vector(M, p, c, B_in), B_out)
380369
end
@@ -561,10 +550,7 @@ requires either a dual basis or the cached basis to be selfdual, for example ort
561550
See also: [`get_vector`](@ref), [`get_basis`](@ref)
562551
"""
563552
function get_coordinates(
564-
M::AbstractManifold,
565-
p,
566-
X,
567-
B::AbstractBasis = default_basis(M, typeof(p)),
553+
M::AbstractManifold, p, X, B::AbstractBasis = default_basis(M, typeof(p)),
568554
)
569555
return _get_coordinates(M, p, X, B)
570556
end
@@ -681,25 +667,13 @@ function _get_coordinates!(M::AbstractManifold, Y, p, X, B::CachedBasis)
681667
return get_coordinates_cached!(M, number_system(M), Y, p, X, B, number_system(B))
682668
end
683669
function get_coordinates_cached!(
684-
M::AbstractManifold,
685-
::ComplexNumbers,
686-
Y,
687-
p,
688-
X,
689-
B::CachedBasis,
690-
::ComplexNumbers,
670+
M::AbstractManifold, ::ComplexNumbers, Y, p, X, B::CachedBasis, ::ComplexNumbers,
691671
)
692672
map!(vb -> conj(inner(M, p, X, vb)), Y, get_vectors(M, p, B))
693673
return Y
694674
end
695675
function get_coordinates_cached!(
696-
M::AbstractManifold,
697-
::𝔽,
698-
Y,
699-
p,
700-
X,
701-
C::CachedBasis,
702-
::RealNumbers,
676+
M::AbstractManifold, ::𝔽, Y, p, X, C::CachedBasis, ::RealNumbers,
703677
) where {𝔽}
704678
map!(vb -> real(inner(M, p, X, vb)), Y, get_vectors(M, p, C))
705679
return Y
@@ -721,10 +695,7 @@ requires either a dual basis or the cached basis to be selfdual, for example ort
721695
See also: [`get_coordinates`](@ref), [`get_basis`](@ref), [`default_basis`](@ref)
722696
"""
723697
@inline function get_vector(
724-
M::AbstractManifold,
725-
p,
726-
c,
727-
B::AbstractBasis = default_basis(M, typeof(p)),
698+
M::AbstractManifold, p, c, B::AbstractBasis = default_basis(M, typeof(p)),
728699
)
729700
return _get_vector(M, p, c, B)
730701
end
@@ -830,11 +801,7 @@ end
830801
function get_vector_orthonormal! end
831802

832803
@inline function _get_vector!(
833-
M::AbstractManifold,
834-
Y,
835-
p,
836-
c,
837-
B::DiagonalizingOrthonormalBasis,
804+
M::AbstractManifold, Y, p, c, B::DiagonalizingOrthonormalBasis,
838805
)
839806
return get_vector_diagonalizing!(M, Y, p, c, B)
840807
end
@@ -917,33 +884,21 @@ When a set of vectors is orthonormalized a set of vectors is returned.
917884
When an [`AbstractBasis`](@ref) is orthonormalized, a [`CachedBasis`](@ref) is returned.
918885
"""
919886
function gram_schmidt(
920-
M::AbstractManifold{𝔽},
921-
p,
922-
B::AbstractBasis{𝔽};
923-
warn_linearly_dependent = false,
924-
return_incomplete_set = false,
925-
skip_linearly_dependent = false,
887+
M::AbstractManifold{𝔽}, p, B::AbstractBasis{𝔽};
888+
warn_linearly_dependent = false, return_incomplete_set = false, skip_linearly_dependent = false,
926889
kwargs...,
927890
) where {𝔽}
928891
V = gram_schmidt(
929-
M,
930-
p,
931-
get_vectors(M, p, B);
932-
warn_linearly_dependent = warn_linearly_dependent,
933-
skip_linearly_dependent = skip_linearly_dependent,
934-
return_incomplete_set = return_incomplete_set,
935-
kwargs...,
892+
M, p, get_vectors(M, p, B);
893+
warn_linearly_dependent = warn_linearly_dependent, skip_linearly_dependent = skip_linearly_dependent,
894+
return_incomplete_set = return_incomplete_set, kwargs...,
936895
)
937896
return CachedBasis(GramSchmidtOrthonormalBasis(𝔽), V)
938897
end
939898
function gram_schmidt(
940-
M::AbstractManifold,
941-
p,
942-
V::AbstractVector;
943-
atol = eps(number_eltype(first(V))),
944-
warn_linearly_dependent = false,
945-
return_incomplete_set = false,
946-
skip_linearly_dependent = false,
899+
M::AbstractManifold, p, V::AbstractVector;
900+
atol = eps(number_eltype(first(V))), warn_linearly_dependent = false,
901+
return_incomplete_set = false, skip_linearly_dependent = false,
947902
kwargs...,
948903
)
949904
N = length(V)

src/exp_log_geo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function exp(M::AbstractManifold, p, X)
1818
end
1919

2020
@doc raw"""
21-
exp_fused(M::AbstractManifold, p, X, t::Number = 1)
21+
exp_fused(M::AbstractManifold, p, X, t::Number)
2222
2323
Compute the exponential map of tangent vector `X` scaled by `t` at point `p`.
2424
Compared to [`exp`](@ref), this method provides the opportunity to

0 commit comments

Comments
 (0)