Skip to content

dq.pwc

pwc(times: ArrayLike, values: ArrayLike, qarray: QArrayLike) -> PWCTimeQArray

Instantiate a piecewise constant (PWC) time-qarray.

A PWC time-qarray 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 qarray.

Note

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

Note

If the returned time-qarray is called for a time \(t\) which does not belong to any time intervals, the returned qarray 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.

  • qarray (qarray-like of shape (n, n)) –

    Constant qarray \(O_0\).

Returns

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

Examples

>>> times = [0.0, 1.0, 2.0]
>>> values = [3.0, -2.0]
>>> qarray = dq.sigmaz()
>>> H = dq.pwc(times, values, qarray)
>>> H(-0.5)
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dia, ndiags=1
[[  â‹…      â‹…   ]
 [  â‹…      â‹…   ]]
>>> H(0.0)
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dia, ndiags=1
[[ 3.+0.j    â‹…   ]
 [   â‹…    -3.+0.j]]
>>> H(0.5)
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dia, ndiags=1
[[ 3.+0.j    â‹…   ]
 [   â‹…    -3.+0.j]]
>>> H(1.0)
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dia, ndiags=1
[[-2.+0.j    â‹…   ]
 [   â‹…     2.+0.j]]