dq.timecallable
timecallable(
f: callable[[float], QArray], *, discontinuity_ts: ArrayLike | None = None
) -> CallableTimeQArray
Instantiate a callable time-qarray.
A callable time-qarray 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) -> QArray
that returns a qarray of shape (..., n, n)
for any time \(t\).
The function f
must return a qarray (not a qarray-like!)
An error is raised if the function f
does not return a qarray. This error
concerns any other qarray-likes. This is enforced to avoid costly
conversions at every time step of the numerical integration.
Parameters
-
f
(function returning qarray of shape (..., n, n))
–
Function with signature
(t: float) -> QArray
that returns the qarray \(f(t)\). -
discontinuity_ts
(array-like, optional)
–
Times at which there is a discontinuous jump in the function values.
Returns
(time-qarray of shape (..., n, n) when called) Callable returning \(O(t)\) for any time \(t\).
Examples
>>> f = lambda t: dq.asqarray([[t, 0], [0, 1 - t]])
>>> H = dq.timecallable(f)
>>> H(0.5)
QArray: shape=(2, 2), dims=(2,), dtype=float32, layout=dense
[[0.5 0. ]
[0. 0.5]]
>>> H(1.0)
QArray: shape=(2, 2), dims=(2,), dtype=float32, layout=dense
[[1. 0.]
[0. 0.]]