If you have computed a gradient or differential and you are not sure whether it is correct.

check_differential(M, F, dF, p=random_point(M), X=random_tangent(M,p))

Check numerivcally whether the differential dF(M,p,X) of F(M,p) is correct.

This implements the method described in Section 4.8 [Boumal2022].

Keyword arguments

  • N (101) – number of points to check within the log_range default range $[10^{-8},10^{0}]$
  • throw_error - (false) throw an error message if the gradient is wrong
  • io – (nothing) provide an IO to print the check result to
  • limits ((1e-8,1)) specify the limits in the log_range
  • log_range (range(limits[1], limits[2]; length=N)) - specify the range of points (in log scale) to sample the gradient line
  • plot- (false) whether to plot the resulting check (if Plots.jl is loaded). The plot is in log-log-scale.
  • retraction_method - (default_retraction_method(M)) retraction method to use for the check
  • slope_tol – (0.1) tolerance for the slope (global) of the approximation
check_gradient(M, F, gradF, p=random_point(M), X=random_tangent(M,p); kwargs...)

Check numerivcally whether the gradient gradF(M,p) of F(M,p) is correct.

This implements the method described in Section 4.8 [Boumal2022].

Its keyword arguments are the same as for the check_differential and Additionally

  • check_vector _ (true) whether or not to check that the gradient is a tangent vector.
(a,b,i,j) = find_best_slope_window(X,Y,window=nothing; slope=2.0, slope_tol=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 are checked. For all these (shifted) windows the regression line is computed (i.e. 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]

Internal methods