expand_entries()#
- static QuadraticOperator.expand_entries(Hc)[source]#
Given \(\tilde{\H}\in\RR^{a \times r(r+1)/2}\), construct the matrix \(\Hhat\in\RR^{a\times r^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:
- Hc(a, r(r+1)/2) ndarray
Matrix that acts on the compressed Kronecker product.
- Returns:
- H(a, r^2) ndarray
Matrix that acts on the full Kronecker product. This matrix is “symmetric” in the sense that
H.reshape((a, r, r))[i]
is symmetric for i = 0, …, r.
Examples
>>> from opinf.operators import QuadraticOperator >>> r = 20 >>> Htilde = np.random.random((r, r * (r + 1) / 2)) >>> Htilde.shape (20, 210) >>> H = QuadraticOperator.expand_entries(Htilde) >>> H.shape (20, 400) >>> q = np.random.random(r) >>> Hq2 = H @ np.kron(q, q) >>> np.allclose(Hq2, Htilde @ QuadraticOperator.ckron(q)) True >>> np.all(QuadraticOperator.compress_entries(G) == Gtilde) True