Hello,
That sounds nice -- you could have a tool that takes as input a manifold M (obtained from a factory) and function handles for r(x), J(x)u and J(x)'v (the matrix-vector product); it could either return a problem structure which can then be passed to trustregions, or it could call trustregions itself and return the answer -- if the latter, then the function should also take an options structure as input, to be passed to trustregions, and an initial guess. That's why it may be easier to do the former.
In any case, the problem should get problem.M = M and there should be a good implementation of cost / grad / approxhess that uses the store. Perhaps it is the given function handles that should use the store, for maximum flexibility.
(About problem.approxhess: if no Hessian is given, trustregions will look for an approximate Hessian first and will find this one; if it is not given, then finite differences of the gradient are used by default. -- it is an approximation of the Riemannian Hessian, so there should potentially be a call to ehess2rhess, which requires access to the Euclidean gradient too. Much of this could indeed be cached.)
Best,
Nicolas