Skip to content

dq.timecallable

timecallable(
    f: callable[[float], Array], *, discontinuity_ts: ArrayLike | None = None
) -> CallableTimeArray

Instantiate a callable time-array.

A callable time-array is defined by \(O(t) = f(t)\) where \(f(t)\) is a time-dependent operator. The function \(f\) is defined by passing a Python function with signature f(t: float) -> Array that returns an array of shape (..., n, n) for any time \(t\).

The function f must return a JAX array (not an array-like object!)

An error is raised if the function f does not return a JAX array. This error concerns any other array-like objects. This is enforced to avoid costly conversions at every time step of the numerical integration.

Parameters

  • f (function returning array of shape (..., n, n)) –

    Function with signature (t: float) -> Array that returns the array \(f(t)\).

  • discontinuity_ts (array_like, optional) –

    Times at which there is a discontinuous jump in the function values.

Returns

(time-array object of shape (..., n, n) when called) Callable object returning \(O(t)\) for any time \(t\).

Examples

>>> f = lambda t: jnp.array([[t, 0], [0, 1 - t]])
>>> H = dq.timecallable(f)
>>> H(0.5)
Array([[0.5, 0. ],
       [0. , 0.5]], dtype=float32)
>>> H(1.0)
Array([[1., 0.],
       [0., 0.]], dtype=float32)