def testaddcdiv_2d(self): t1 = TensorBase(np.array([[1, 2], [1, 2]])) t2 = TensorBase(np.array([[1, 2], [1, 2]])) mat = TensorBase(np.array([[2, 3], [3, 4]])) t1.addcdiv_(t2, mat, value=2) self.assertTrue(np.array_equal(t1.data, [[4., 5.], [5., 6.]]))
def testaddcdiv_1d(self): t1 = TensorBase(np.array([1, 2, 3])) t2 = TensorBase(np.array([2, 5, 4])) mat = TensorBase(np.array([5])) t1.addcdiv_(t2, mat, value=2) self.assertTrue(np.array_equal(t1.data, [6., 5.8, 6.5]))