ckron_indices()#
- static QuadraticOperator.ckron_indices(r)[source]#
Construct a mask for efficiently computing the compressed Kronecker product.
This method provides a faster way to evaluate
ckron()
when the state dimensionr
is known a priori.- Parameters:
- rint
State dimension.
- Returns:
- maskndarray
Compressed Kronecker product mask.
Examples
>>> from opinf.operators import QuadraticOperator >>> r = 20 >>> mask = QuadraticOperator.ckron_indices(r) >>> q = np.random.random(r) >>> np.allclose(QuadraticOperator.ckron(q), np.prod(q[mask], axis=1)) True