def test_10(self): x = np.random.randn(9, 10) y = np.random.randn(9, 10) u = signal.grad(x, 0) v = signal.gradT(y, 0) err = np.dot(x.ravel(), v.ravel()) - np.dot(y.ravel(), u.ravel()) assert np.abs(err) < 5e-14 u = signal.grad(x, 1) v = signal.gradT(y, 1) err = np.dot(x.ravel(), v.ravel()) - np.dot(y.ravel(), u.ravel()) assert np.abs(err) < 5e-14
def test_11(self): x = np.random.randn(9, 10) y = np.random.randn(10, 10) u = signal.grad(x, 0, zero_pad=True) v = signal.gradT(y, 0, zero_pad=True) err = np.dot(x.ravel(), v.ravel()) - np.dot(y.ravel(), u.ravel()) assert np.abs(err) < 1e-14 y = np.random.randn(9, 11) u = signal.grad(x, 1, zero_pad=True) v = signal.gradT(y, 1, zero_pad=True) err = np.dot(x.ravel(), v.ravel()) - np.dot(y.ravel(), u.ravel()) assert np.abs(err) < 1e-14
def cnst_AT(self, X): r"""Compute :math:`A^T \mathbf{x}` where :math:`A \mathbf{x}` is a component of ADMM problem constraint. In this case :math:`A^T \mathbf{x} = (G_r^T \;\; G_c^T) \mathbf{x}`. """ return np.sum(np.concatenate( [gradT(X[..., ax], ax)[..., np.newaxis] for ax in self.axes], axis=X.ndim-1), axis=X.ndim-1)