compress_entries()#
- static QuadraticOperator.compress_entries(H)[source]#
Given \(\Hhat\in\RR^{a\times r^2}\), construct the matrix \(\tilde{\H}\in\RR^{a \times r(r+1)/2}\) such that \(\Hhat[\qhat\otimes\qhat] = \tilde{\H}[\qhat\,\hat{\otimes}\,\qhat]\) for all \(\qhat\in\RR^{r}\) where \(\hat{\otimes}\) is the compressed Kronecker product (see
ckron()
).- Parameters:
- H(a, r^2) ndarray
Matrix that acts on the full Kronecker product.
- Returns:
- Hc(a, r(r+1)/2) ndarray
Matrix that acts on the compressed Kronecker product.
Examples
>>> from opinf.operators import QuadraticOperator >>> r = 20 >>> H = np.random.random((r, r**2)) >>> H.shape (20, 400) >>> Htilde = QuadraticOperator.compress_entries(H) >>> Htilde.shape (20, 210) >>> q = np.random.random(r) >>> Hq2 = H @ np.kron(q, q) >>> np.allclose(Hq2, Htilde @ QuadraticOperator.ckron(q)) True