ckron()#
- static QuadraticOperator.ckron(state, checkdim=False)[source]#
Calculate the compressed Kronecker product of a vector with itself.
For a vector \(\qhat = [~\hat{q}_{1}~~\cdots~~\hat{q}_{r}~]\trp\), the Kronecker product of \(\qhat\) with itself is given by
\[\begin{split}\qhat \otimes \qhat = \left[\begin{array}{c} \hat{q}_{1}\qhat \\ \vdots \\ \hat{q}_{r}\qhat \end{array}\right] = \left[\begin{array}{c} \hat{q}_{1}^{2} \\ \hat{q}_{1}\hat{q}_{2} \\ \vdots \\ \hat{q}_{1}\hat{q}_{r} \\ \hat{q}_{1}\hat{q}_{2} \\ \hat{q}_{2}^{2} \\ \vdots \\ \hat{q}_{2}\hat{q}_{r} \\ \vdots \hat{q}_{r}^{2} \end{array}\right] \in\RR^{r^2}.\end{split}\]Cross terms \(\hat{q}_i \hat{q}_j\) for \(i \neq j\) appear twice in \(\qhat\otimes\qhat\). The compressed Kronecker product \(\qhat\,\hat{\otimes}\,\qhat\) consists of the unique terms of \(\qhat\otimes\qhat\):
\[\begin{split}\qhat\,\hat{\otimes}\,\qhat = \left[\begin{array}{c} \hat{q}_{1}^2 \\ \hat{q}_{2}\qhat_{1:2} \\ \vdots \\ \hat{q}_{r}\qhat_{1:r} \end{array}\right] = \left[\begin{array}{c} \hat{q}_{1}^2 \\ \hat{q}_{1}\hat{q}_{2} \\ \hat{q}_{2}^{2} \\ \\ \vdots \\ \hline \hat{q}_{1}\hat{q}_{r} \\ \hat{q}_{2}\hat{q}_{r} \\ \vdots \\ \hat{q}_{r}^{2} \end{array}\right] \in \RR^{r(r+1)/2}, \qquad \qhat_{1:i} = \left[\begin{array}{c} \hat{q}_{1} \\ \vdots \\ \hat{q}_{i} \end{array}\right] \in\RR^{i}.\end{split}\]For matrices, the product is computed columnwise:
\[\begin{split}\left[\begin{array}{c|c|c} & & \\ \qhat_0 & \cdots & \qhat_{k-1} \\ & & \end{array}\right] \hat{\otimes} \left[\begin{array}{ccc} & & \\ \qhat_0 & \cdots & \qhat_{k-1} \\ & & \end{array}\right] = \left[\begin{array}{ccc} & & \\ \qhat_0\,\hat{\otimes}\,\qhat_0 & \cdots & \qhat_{k-1}\,\hat{\otimes}\,\qhat_{k-1} \\ & & \end{array}\right] \in \RR^{r(r+1)/2 \times k}.\end{split}\]- Parameters:
- state(r,) or (r, k) numpy.ndarray
State vector or matrix where each column is a state vector.
- Returns:
- product(r(r+1)/2,) or (r(r+1)/2, k) ndarray
The compressed Kronecker product of
state
with itself.