'Test gradient for affine_prod'

def test_affine_prod(self):

    expr = affine_prod(self.C, self.A)
    self.C.value = np.matrix([[1, (-2)], [3, 4], [(-1), (-3)]])
    self.A.value = np.matrix([[3, 2], [(-5), 1]])
    self.assertItemsAlmostEqual(expr.grad[self.C].todense(), np.matrix([[3, 0, 0, 2, 0, 0], [0, 3, 0, 0, 2, 0], [0, 0, 3, 0, 0, 2], [(-5), 0, 0, 1, 0, 0], [0, (-5), 0, 0, 1, 0], [0, 0, (-5), 0, 0, 1]]))
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), np.matrix([[1, 3, (-1), 0, 0, 0], [(-2), 4, (-3), 0, 0, 0], [0, 0, 0, 1, 3, (-1)], [0, 0, 0, (-2), 4, (-3)]]))
