Functional

Collection of factories for functional iteration Output of nest and fold function factories can be composed with regular JAX functions

sympint.functional.fold(mappings: Sequence[Callable[[...], jax.Array]]) Callable[[...], jax.Array][source]

Create a function that sequentially applies mappings from a given list

Parameters:

mappings (Sequence[Callable[[Array, *Any], Array]]) – ordered sequence of transformation (identical signature) functions [R^n x … -> R^n]

Return type:

Callable[[Array, *Any], Array]

Note

All mappings are assumed to have identical signature f(x, *args) and R^n x … -> R^n Fold over a list of mappings is equivalent to the following Python loop:

for f in fs:

x = f(x, *args)

sympint.functional.fold_list(mappings: Sequence[Callable[[...], jax.Array]]) Callable[[...], jax.Array][source]

Create a function that sequentially applies mappings from a given list And accumulates intermediate results

Parameters:

mappings (Sequence[Callable[[Array, *Any], Array]]) – ordered sequence of transformation (identical signature) functions [R^n x … -> R^n]

Return type:

Callable[[Array, *Any], Array]

Note

All mappings are assumed to have identical signature f(x, *args) and R^n x … -> R^n Fold over a list of mappings is equivalent to the following Python loop:

xs = [] for f in fs:

x = f(x, *args) xs.append(x)

sympint.functional.nest(length: int, mapping: Callable[[...], jax.Array]) Callable[[...], jax.Array][source]

Create a function that iteratively applies a state transformation mapping

Parameters:
  • length (int, positive) – number of iterations to perform

  • mapping (Callable[[Array, *Any], Array]) – state transformation mapping R^n x … -> R^n

Return type:

Callable[[Array, *Any], Array]

Note

Nest is equivalent to the following Python loop:

for _ in range(n):

x = f(x, *args)

sympint.functional.nest_list(length: int, mapping: Callable[[...], jax.Array]) Callable[[...], jax.Array][source]

Create a function that iteratively applies a state transformation mapping And accumulates intermediate results

Parameters:
  • length (int, positive) – number of iterations to perform

  • mapping (Callable[[Array, *Any], Array]) – state transformation mapping R^n x … -> R^n

Return type:

Callable[[Array, *Any], Array]

Note

Initial value is not included in the output, output length is equal to the number of iterations Accumulate is equivalent to the following Python loop:

xs = [] for _ in range(n):

x = f(x, *args) xs.append(x)