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_fn
to a tuple(iteration, constants, state, compute_error)
to output a new state, using context provided in iteration and constants.body_fn
is iterated (inner_iterations -1) times, and one last time with thecompute_error
flag toTrue
, indicating that additional computational effort can be spent on recalculating the latest error (errors
are 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_fn
returns 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_fn
will 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_fn
upon termination.