ott.math.fixed_point_loop.fixpoint_iter#
- ott.math.fixed_point_loop.fixpoint_iter(cond_fn, body_fn, min_iterations, max_iterations, inner_iterations, constants, state)[source]#
Implementation of a fixed point loop.
This fixed point loop iterator applies
body_fnto a tuple(iteration, constants, state, compute_error)to output a new state, using context provided in iteration and constants.body_fnis iterated (inner_iterations -1) times, and one last time with thecompute_errorflag toTrue, indicating that additional computational effort can be spent on recalculating the latest error (errorsare stored as the first element of the state tuple).upon termination of these
inner_iterations, the loop is continued if iteration is smaller thanmin_iterations, stopped if equal/larger thanmax_iterations, and interrupted ifcond_fnreturns False.- Parameters:
cond_fn (
Callable[[int,Any,Any],bool]) – termination condition functionbody_fn (
Callable[[Any,Any,Any,Any],Any]) – body loop instructionsmin_iterations (
int) – lower bound on the total amount of fixed point iterationsmax_iterations (
int) – upper bound on the total amount of fixed point iterationsinner_iterations (
int) – number of iterationsbody_fnwill be executed successively before callingcond_fn.constants (
Any) – constant (during loop) parameters passed on to bodystate (
Any) – state variable
- Returns:
outputs state returned by
body_fnupon termination.