Home > manopt > core > applyStatsfun.m

# applyStatsfun

## PURPOSE

Apply the statsfun function to a stats structure (for solvers).

## SYNOPSIS

function stats = applyStatsfun(problem, x, storedb, key, options, stats)

## DESCRIPTION

``` Apply the statsfun function to a stats structure (for solvers).

function stats = applyStatsfun(problem, x, storedb, key, options, stats)

Applies the options.statsfun user supplied function (if it was provided)
to the stats structure, and returns the (possibly) modified stats
structure.

storedb is a StoreDB object, key is the StoreDB key to point x.

Note: if statsfun accepts a store structure as input, this structure can
be read but not modified (modifications will be lost) ; the store
structure will contain the store.shared field.

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:
• arc Adaptive regularization by cubics (ARC) minimization algorithm for Manopt
• barzilaiborwein Riemannian Barzilai-Borwein solver with non-monotone line-search.
• rlbfgs Riemannian limited memory BFGS solver for smooth objective functions.
• pso Particle swarm optimization (PSO) for derivative-free minimization.
• steepestdescent Steepest descent (gradient descent) minimization algorithm for Manopt.
• trustregions Riemannian trust-regions solver for optimization on manifolds.

## SOURCE CODE

```0001 function stats = applyStatsfun(problem, x, storedb, key, options, stats)
0002 % Apply the statsfun function to a stats structure (for solvers).
0003 %
0004 % function stats = applyStatsfun(problem, x, storedb, key, options, stats)
0005 %
0006 % Applies the options.statsfun user supplied function (if it was provided)
0007 % to the stats structure, and returns the (possibly) modified stats
0008 % structure.
0009 %
0010 % storedb is a StoreDB object, key is the StoreDB key to point x.
0011 %
0012 % Note: if statsfun accepts a store structure as input, this structure can
0013 % be read but not modified (modifications will be lost) ; the store
0014 % structure will contain the store.shared field.
0015 %
0017
0018 % This file is part of Manopt: www.manopt.org.
0019 % Original author: Nicolas Boumal, April 3, 2013.
0020 % Contributors:
0021 % Change log:
0022 %
0023 %   April 3, 2015 (NB):
0024 %       Works with the new StoreDB class system.
0025
0026     if isfield(options, 'statsfun')
0027
0028         switch nargin(options.statsfun)
0029             case 3
0030                 stats = options.statsfun(problem, x, stats);
0031             case 4
0032                 % Obtain, pass along, and save the store for x.
0033                 % get/setWithShared must come in pairs.
0034                 store = storedb.getWithShared(key);
0035                 stats = options.statsfun(problem, x, stats, store);
0036                 storedb.setWithShared(store, key);
0037             otherwise
0038                 warning('manopt:statsfun', ...
0039                         'statsfun unused: wrong number of inputs');
0040         end
0041     end
0042
0043 end```

Generated on Mon 10-Sep-2018 11:48:06 by m2html © 2005