コード例 #1
0
 def test_plus_onesize_negative_matrix(self):
     first_matrix = Matrix.make_from_list([[1, 1]])
     second_matrix = Matrix.make_from_list([[-2, 2]])
     result_matrix = MatrixOperations.add_matrix(first_matrix,
                                                 second_matrix)
     self.assertTrue(result_matrix.data_lines[0][0] == -1
                     and result_matrix.data_lines[0][1] == 3)
コード例 #2
0
 def test_plus_onesize_diff_char_matrix(self):
     first_matrix = Matrix.make_from_list([[1, 1]])
     second_matrix = Matrix.make_from_list([[-1, -1]])
     result_matrix = MatrixOperations.add_matrix(first_matrix,
                                                 second_matrix)
     self.assertTrue(result_matrix.data_lines[0][0] == 0
                     and result_matrix.data_lines[0][1] == 0)
コード例 #3
0
 def test_plus_3x2_matrix(self):
     first_matrix = Matrix.make_from_list([[1, 1], [2, 2], [3, 3]])
     second_matrix = Matrix.make_from_list([[-1, -1], [-1, -1], [-1, -1]])
     result_matrix = MatrixOperations.add_matrix(first_matrix,
                                                 second_matrix)
     self.assertTrue(result_matrix.data_lines[0][0] == 0
                     and result_matrix.data_lines[1][1] == 1
                     and result_matrix.data_lines[2][1] == 2)
コード例 #4
0
 def test_plus_diffsize_matrix(self):
     first_matrix = Matrix.make_from_list([[1, 1]])
     second_matrix = Matrix.make_from_list([[-1]])
     with self.assertRaises(MatrixOperationsError):
         MatrixOperations.add_matrix(first_matrix, second_matrix)
コード例 #5
0
 def sum(self):
     return MatrixOperations.add_matrix(self.matrix1,
                                        self.matrix2).get_data_lines()