0001 function checkmanifold(M)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 assert(isstruct(M), 'M must be a structure.');
0021
0022
0023 list_of_functions = {'name', 'dim', 'inner', 'norm', 'typicaldist', ...
0024 'proj', 'tangent', 'egrad2rgrad', 'retr', ...
0025 'rand', 'randvec', 'zerovec', 'lincomb'};
0026 for k = 1 : numel(list_of_functions)
0027 field = list_of_functions{k};
0028 if ~(isfield(M, field) && isa(M.(field), 'function_handle'))
0029 fprintf('M.%s must be a function handle.\n', field);
0030 end
0031 end
0032
0033
0034 list_of_functions = {'dist', 'ehess2rhess', 'exp', 'log', 'hash', ...
0035 'transp', 'pairmean', 'vec', 'mat', ...
0036 'vecmatareisometries'};
0037 for k = 1 : numel(list_of_functions)
0038 field = list_of_functions{k};
0039 if ~(isfield(M, field) && isa(M.(field), 'function_handle'))
0040 fprintf('M.%s should be a function handle.\n', field);
0041 end
0042 end
0043
0044
0045 try
0046 x = M.rand();
0047 v = M.randvec(x);
0048 t = randn(1);
0049 y = M.exp(x, v, t);
0050 d = M.dist(x, y);
0051 fprintf('dist(x, M.exp(x, v, t)) - abs(t)*M.norm(x, v) = %g (should be zero)\n', d - abs(t)*M.norm(x, v));
0052 catch up
0053 fprintf('Couldn''t check exp and dist.\n');
0054
0055 end
0056
0057 end
0058