compress_entries()#

static CubicOperator.compress_entries(G)[source]#

Given \(\Ghat\in\RR^{a\times r^2}\), construct the matrix \(\tilde{\G}\in\RR^{a \times r(r+1)(r+2)/6}\) such that \(\Ghat[\qhat\otimes\qhat\otimes\qhat] = \tilde{\G}[\qhat\hat{\otimes}\qhat\hat{\otimes}\qhat]\) for all \(\qhat\in\RR^{r}\) where \(\cdot\hat{\otimes}\cdot\hat{\otimes}\cdot\) is the compressed cubic Kronecker product (see ckron()).

Parameters
G(a, r^3) ndarray

Matrix that acts on the full cubic Kronecker product.

Returns
Gc(a, r(r+1)(r+2)/6) ndarray

Matrix that acts on the compressed cubic Kronecker product.

Examples

>>> from opinf.operators import CubicOperator
>>> r = 20
>>> G = np.random.random((r, r**3))
>>> G.shape
(20, 8000)
>>> Gtilde = CubicOperator.compress_entries(G)
>>> Gtilde.shape
(20, 1540)
>>> q = np.random.random(r)
>>> Gq3 = G @ np.kron(q, np.kron(q, q))
>>> np.allclose(Gq3, Gtilde @ CubicOperator.ckron(q))
True