예제 #1
0
 def test_row_combine_called(self):
     
     A = np.array([[1, 2], [4, 3]])
     ls = LinearSystem(A)
     ls.row_combine = MagicMock()
     ls.row_echelon()
     assert ls.row_combine.called
예제 #2
0
 def test_inverse_private(self):
     
     A = np.array([[11, 2, 5],[51, 22, 17],[11, 7, 1]])
     ls = LinearSystem(A)
     np.testing.assert_array_almost_equal(ls.inverse(),
                                          np.linalg.inv(A),
                                          decimal=6)
예제 #3
0
 def test_gauss_solve(self):
     
     A = np.array([[1, 3, 5],[5, 2, 2],[1, 7, 1]])
     b = np.array([1, 3, 4])
     ls = LinearSystem(A, b)
     np.testing.assert_array_almost_equal(ls.gauss_solve(),
                                          np.linalg.solve(A, b),
                                          decimal=6)
예제 #4
0
 def test_reduced_row_echelon(self):
     
     A = np.array([[1, 3, 5],[5, 2, 2],[1, 7, 1]])
     b = np.array([1, 3, 4])
     ls = LinearSystem(A, b)
     ls.reduced_row_echelon()
     np.testing.assert_array_almost_equal(ls.mat[:,-1],
                                          np.linalg.solve(A, b),
                                          decimal=6)
예제 #5
0
 def test_back_substitute(self):
     
     A = np.array([[1, 3, 5],[5, 2, 2],[1, 7, 1]])
     b = np.array([1, 3, 4])
     ls = LinearSystem(A, b)
     ls.row_echelon()
     np.testing.assert_array_almost_equal(ls.back_substitute(),
                                          np.linalg.solve(A, b),
                                          decimal=6)
예제 #6
0
 def test_row_echelon(self):
     
     A = np.array([[1, 3, 4],[5, 4, 2],[1, 7, 9]])
     ls = LinearSystem(A)
     ls.row_echelon() 
     np.testing.assert_array_almost_equal(ls.mat, 
                                          np.array([[ 5., 4., 2.],
                                                    [0., 6.2, 8.6],
                                                    [ 0., 0., 0.5483871]]),                                                      decimal=6)
예제 #7
0
 def test_row_echelon_private(self):
     
     A = np.array([[1, 3, 5],[5, 2, 2],[1, 7, 1]])
     ls = LinearSystem(A)
     ls.row_echelon() 
     np.testing.assert_array_almost_equal(ls.mat, 
                                          np.array([[5., 2., 2.],
                                                    [0., 6.6, 0.6],
                                                    [0., 0., 4.36363636]]),                                                      decimal=6)