Numerical Verification

ManifoldsBase.check_inverse_retractionFunction
check_inverse_retraction(
    M::AbstractManifold,
    inverse_rectraction_method::AbstractInverseRetractionMethod,
    p=rand(M),
    X=rand(M; vector_at=p);
    #
    exactness_tol::Real = 1e-12,
    io::Union{IO,Nothing} = nothing,
    limits::Tuple = (-8.0, 0.0),
    log_range::AbstractVector = range(limits[1], limits[2]; length=N),
    N::Int = 101,
    name::String = "inverse retraction",
    plot::Bool = false,
    second_order::Bool = true
    slope_tol::Real = 0.1,
    error::Symbol = :none,
    window = nothing,
)

Check numerically wether the inverse retraction inverse_retraction_method is correct. This requires the exp and norm functions to be implemented for the AbstractManifold M.

This implements a method similar to [Bou23, Section 4.8 or Section 6.8].

Note that if the errors are below the given tolerance and the method is exact, no plot is generated,

Keyword arguments

  • exactness_tol: if all errors are below this tolerance, the inverse retraction is considered to be exact
  • io: provide an IO to print the result to
  • limits: specify the limits in the log_range, that is the exponent for the range
  • log_range: specify the range of points (in log scale) to sample the length of the tangent vector X
  • N: number of points to verify within the log_range default range $[10^{-8},10^{0}]$
  • name: name to display in the plot
  • plot: whether to plot the result (see plot_slope) The plot is in log-log-scale. This is returned and can then also be saved.
  • second_order: check whether the retraction is of second order. if set to false, first order is checked.
  • slope_tol: tolerance for the slope (global) of the approximation
  • error: specify how to report errors: :none, :info, :warn, or :error are available
  • window: specify window sizes within the log_range that are used for the slope estimation. the default is, to use all window sizes 2:N.
source
ManifoldsBase.check_retractionFunction
check_retraction(
    M::AbstractManifold,
    rectraction_method::AbstractRetractionMethod,
    p=rand(M),
    X=rand(M; vector_at=p);
    #
    exactness_tol::Real = 1e-12,
    io::Union{IO,Nothing} = nothing,
    limits::Tuple = (-8.0, 0.0),
    log_range::AbstractVector = range(limits[1], limits[2]; length=N),
    N::Int = 101,
    name::String = "retraction",
    plot::Bool = false,
    second_order::Bool = true
    slope_tol::Real = 0.1,
    error::Symbol = :none,
    window = nothing,
)

Check numerically wether the retraction vector_transport_to is correct, by selecting a set of points $q_i = \exp_p (t_i X)$ where $t$ takes all values from log_range, to then compare parallel_transport_to to the vector_transport_method applied to the vector Y.

This requires the exp, parallel_transport_to and norm function to be implemented for the AbstractManifold M.

This implements a method similar to [Bou23, Section 4.8 or Section 6.8].

Note that if the errors are below the given tolerance and the method is exact, no plot is generated,

Keyword arguments

  • exactness_tol: if all errors are below this tolerance, the retraction is considered to be exact
  • io: provide an IO to print the result to
  • limits: specify the limits in the log_range, that is the exponent for the range
  • log_range: specify the range of points (in log scale) to sample the length of the tangent vector X
  • N: number of points to verify within the log_range default range $[10^{-8},10^{0}]$
  • name: name to display in the plot
  • plot: whether to plot the result (if Plots.jl is loaded). The plot is in log-log-scale. This is returned and can then also be saved.
  • second_order: check whether the retraction is of second order. if set to false, first order is checked.
  • slope_tol: tolerance for the slope (global) of the approximation
  • error: specify how to report errors: :none, :info, :warn, or :error are available
  • window: specify window sizes within the log_range that are used for the slope estimation. the default is, to use all window sizes 2:N.
source
ManifoldsBase.check_vector_transportFunction
check_vector_transport(
    M::AbstractManifold,
    vector_transport_method::AbstractVectorTransportMethod,
    p=rand(M),
    X=rand(M; vector_at=p),
    Y=rand(M; vector_at=p);
    #
    exactness_tol::Real = 1e-12,
    io::Union{IO,Nothing} = nothing,
    limits::Tuple = (-8.0, 0.0),
    log_range::AbstractVector = range(limits[1], limits[2]; length=N),
    N::Int = 101,
    name::String = "inverse retraction",
    plot::Bool = false,
    second_order::Bool = true
    slope_tol::Real = 0.1,
    error::Symbol = :none,
    window = nothing,
)

Check numerically wether the retraction vector_transport_to is correct, by selecting a set of points $q_i = \exp_p (t_i X)$ where $t$ takes all values from log_range, to then compare parallel_transport_to to the vector_transport_method applied to the vector Y.

This requires the exp, parallel_transport_to and norm function to be implemented for the AbstractManifold M.

This implements a method similar to [Bou23, Section 4.8 or Section 6.8].

Note that if the errors are below the given tolerance and the method is exact, no plot is generated,

Keyword arguments

  • exactness_tol: if all errors are below this tolerance, the differential is considered to be exact
  • io: provide an IO to print the result to
  • limits: specify the limits in the log_range, that is the exponent for the range
  • log_range: specify the range of points (in log scale) to sample the differential line
  • N: number of points to verify within the log_range default range $[10^{-8},10^{0}]$
  • name: name to display in the plot
  • plot: whether to plot the result (if Plots.jl is loaded). The plot is in log-log-scale. This is returned and can then also be saved.
  • second_order: check whether the retraction is of second order. if set to false, first order is checked.
  • slope_tol: tolerance for the slope (global) of the approximation
  • error: specify how to report errors: :none, :info, :warn, or :error are available
  • window: specify window sizes within the log_range that are used for the slope estimation. the default is, to use all window sizes 2:N.
source

Internal functions

The following functions split the check into several parts, for example looking for the best fitting window and finding out the best slope, or plotting the slope.

ManifoldsBase.find_best_slope_windowFunction
(a, b, i, j) = find_best_slope_window(X, Y, window=nothing; slope::Real=2.0, slope_tol::Real=0.1)

Check data X,Y for the largest contiguous interval (window) with a regression line fitting “best”. Among all intervals with a slope within slope_tol to slope the longest one is taken. If no such interval exists, the one with the slope closest to slope is taken.

If the window is set to nothing (default), all window sizes 2,...,length(X) are checked. You can also specify a window size or an array of window sizes.

For each window size, all its translates in the data is checked. For all these (shifted) windows the regression line is computed (with a,b in a + t*b) and the best line is computed.

From the best line the following data is returned

  • a, b specifying the regression line a + t*b
  • i, j determining the window, i.e the regression line stems from data X[i], ..., X[j]
Note

This function has to be implemented using some statistics package. loading Statistics.jl provides a default implementation.

source
ManifoldsBase.plot_slopeMethod
plot_slope(x, y;
    slope=2,
    line_base=0,
    a=0,
    b=2.0,
    i=1,
    j=length(x)
)

Plot the result from the verification functions on data x,y with two comparison lines

  1. line_base + tslope as the global slope(s) the plot could have
  2. a + b*t on the interval [x[i], x[j]] for some (best fitting) comparison slope
Note

This function has to be implemented for a certain plotting package. loading Plots.jl provides a default implementation.

source