Skip to content

dq.pwc

pwc(times: ArrayLike, values: ArrayLike, array: ArrayLike) -> PWCTimeArray

Instantiate a piecewise constant (PWC) time-array.

A PWC time-array takes constant values over some time intervals. It is defined by $$ O(t) = \left(\sum_{k=0}^{N-1} c_k\; \Omega_{[t_k, t_{k+1}[}(t)\right) O_0 $$ where \(c_k\) are constant values, \(\Omega_{[t_k, t_{k+1}[}\) is the rectangular window function defined by \(\Omega_{[t_a, t_b[}(t) = 1\) if \(t \in [t_a, t_b[\) and \(\Omega_{[t_a, t_b[}(t) = 0\) otherwise, and \(O_0\) is a constant array.

Note

The argument times must be sorted in ascending order, but does not need to be evenly spaced.

Note

If the returned time-array is called for a time \(t\) which does not belong to any time intervals, the returned array is null.

Parameters

  • times (array_like of shape (N+1,)) –

    Time points \(t_k\) defining the boundaries of the time intervals, where N is the number of time intervals.

  • values (array_like of shape (..., N)) –

    Constant values \(c_k\) for each time interval.

  • array (array_like of shape (n, n)) –

    Constant array \(O_0\).

Returns

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

Examples

>>> times = [0.0, 1.0, 2.0]
>>> values = [3.0, -2.0]
>>> array = dq.sigmaz()
>>> H = dq.pwc(times, values, array)
>>> H(-0.5)
Array([[ 0.+0.j,  0.+0.j],
       [ 0.+0.j, -0.+0.j]], dtype=complex64)
>>> H(0.0)
Array([[ 3.+0.j,  0.+0.j],
       [ 0.+0.j, -3.+0.j]], dtype=complex64)
>>> H(0.5)
Array([[ 3.+0.j,  0.+0.j],
       [ 0.+0.j, -3.+0.j]], dtype=complex64)
>>> H(1.0)
Array([[-2.+0.j, -0.+0.j],
       [-0.+0.j,  2.-0.j]], dtype=complex64)