def testNew(self): A = CuMatrix() self.assertIsNotNone(A) self.assertEqual(0, A.num_rows()) self.assertEqual(0, A.num_cols()) dim = A.dim() self.assertEqual(0, dim.rows) self.assertEqual(0, dim.cols) A = CuMatrix.new_from_size(10, 10) self.assertIsNotNone(A) self.assertEqual(10, A.num_rows()) self.assertEqual(10, A.num_cols()) dim = A.dim() self.assertEqual(10, dim.rows) self.assertEqual(10, dim.cols) A = CuMatrix.new_from_matrix(Matrix([[2, 3], [5, 7]])) self.assertIsNotNone(A) self.assertEqual(2, A.num_rows()) self.assertEqual(2, A.num_cols()) B = CuMatrix.new_from_other(A) self.assertIsNotNone(B) self.assertEqual(2, B.num_rows()) self.assertEqual(2, B.num_cols())
def testResize(self): A = CuMatrix() A.resize(10, 10) self.assertEqual(10, A.num_rows()) self.assertEqual(10, A.num_cols()) # A.resize(-1, -1) #This hard-crashes A.resize(0, 0)