astronomix._stencil_operations._stencil_operations#
Convenience functions for operations that combine multiple elements of an array based on some stencil, e.g. b_i <- a_{i + 1} + a_{i - 1}. Allows for code “closer to the math”.
Module Contents#
Functions#
Periodic roll of |
API#
- astronomix._stencil_operations._stencil_operations.custom_roll(input_array: jax.numpy.ndarray, shift: int, axis: int) jax.numpy.ndarray[source]#
Periodic roll of
input_arraybyshiftalongaxis.Equivalent to
jnp.rollbut expressed via two static slices and a concatenate, which keepsshift/axiscompile-time constants so the stencil helpers built on top of it fuse cleanly.- Args:
input_array: The array to roll. shift: The (signed) number of positions to roll by. axis: The axis along which to roll.
- Returns:
The rolled array.