def test_multiply(self):
     self.matrix = MatrixCuda.identity(3)
     other = MatrixCuda([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     self.assertEqual(self.matrix * other, other)
     self.assertEqual(MatrixCuda.zero(3, 3) * self.matrix,
                      MatrixCuda.zero(3, 3))
     self.matrix = MatrixCuda([[1, 1, 1], [2, 2, 2]])
     self.assertEqual((self.matrix * self.matrix.T).size(), (2, 2))
     self.assertEqual((self.matrix.T * self.matrix).size(), (3, 3))
     self.matrix = MatrixCuda([[-1, 0], [0, 1]])
     self.assertEqual(self.matrix * self.matrix, MatrixCuda.identity(2))
 def test_property(self):
     self.matrix = MatrixCuda.identity(3)
     new = MatrixCuda()
     new.value = self.matrix.value
     self.assertEqual(new.size(), self.matrix.size())
     self.matrix.value = [[1, 2, 3], [4, 5, 6]]
     np.testing.assert_equal(self.matrix.value, [[1, 2, 3], [4, 5, 6]])
     np.testing.assert_equal(self.matrix.size(), (2, 3))
 def test_lu(self):
     self.matrix = MatrixCuda()
     array = [[1, 0, 4], [2, 5, 0], [1, 5, 2]]
     self.matrix.value = array
     P, L, U = self.matrix.LU()
     self.assertEqual(P * self.matrix, L * U)
     self.matrix = MatrixCuda.identity(10)
     P, L, U = self.matrix.LU()
     self.assertEqual(self.matrix, L)
     self.assertEqual(self.matrix, U)
     self.assertEqual(self.matrix, L * U)
 def test_transpose(self):
     self.matrix = MatrixCuda.identity(3)
     self.assertEqual(self.matrix, self.matrix.T)
     new = MatrixCuda([[1, 2, 3], [4, 5, 6]])
     self.assertEqual(new.T.size(), (3, 2))
     self.assertEqual(new, new.T.T)
 def test_add2(self):
     self.matrix = MatrixCuda.identity(3)
     other = MatrixCuda([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     new = self.matrix + other - other
     np.testing.assert_equal(self.matrix.value, new.value)
 def test_identity(self):
     self.matrix = MatrixCuda.identity(5)
     func = lambda x, y: 1 if x == y else 0
     ident_array = [[func(i, j) for i in range(5)] for j in range(5)]
     np.testing.assert_equal(self.matrix.value, ident_array)
     self.assertRaises(ValueError, self.matrix.identity, *(-1,))