def test_solve_lower_triangular(self):
     l = array([[3, 0, 0], [6, 4, 0], [8, 2, 4]], dtype=numpy.double)
     b = array([3, 26, 42], dtype=numpy.double)
     x = solve_lower_triangular(l, b)
     print "x=", x
     x_actual = scipy_solve(l, b)
     print 'x_actual=', x_actual
Esempio n. 2
0
 def test_gauss_seidel(self):
     # create random sdd matrix
     A = randn(37,37) + 37*numpy.diag(numpy.ones(37))
     b = randn(37)
     y_actual = scipy_solve(A,b)
     y,_ = gauss_seidel(A,b)
     error = norm(y - y_actual)
     self.assertLess(error, 1e-4)
Esempio n. 3
0
 def test_jacobi_epsilon(self):
     # create random sdd matrix
     A = randn(37,37) + 37*numpy.diag(numpy.ones(37))
     b = randn(37)
     epsilon=1e-12
     y_actual = scipy_solve(A,b)
     y,_ = jacobi(A,b)
     error = norm(y - y_actual)
     self.assertLess(error, 1e-8)
    def test_jacobi_highn(self):
        A, b = five_diagonal_system(20)
        xactual = scipy_solve(A,b)
        x, n = jacobi(A,b)
        error = norm(xactual - x)
        self.assertLess(error,1e-7)

        A, b = five_diagonal_system(40)
        xactual = scipy_solve(A,b)
        x, n = jacobi(A,b,epsilon=1e-12)
        error = norm(xactual - x)
        self.assertLess(error,1e-7)

        A, b = five_diagonal_system(8)
        xactual = scipy_solve(A,b)
        x, n = jacobi(A,b,epsilon=1e-3)
        error = norm(xactual - x)
        self.assertLess(error,1e-2)
    def test_gauss_hign(self):
        A, b = five_diagonal_system(20)
        xactual = scipy_solve(A,b)
        x, n = gauss_seidel(A,b)
        error = norm(xactual - x)
        self.assertLess(error,1e-7)

        A, b = five_diagonal_system(40)
        xactual = scipy_solve(A,b)
        x, n = gauss_seidel(A,b)
        error = norm(xactual - x)
        self.assertLess(error,1e-7)
 
        A, b = five_diagonal_system(8)
        xactual = scipy_solve(A,b)
        x, n = gauss_seidel(A,b,epsilon=1e-3)
        error = norm(xactual - x)
        self.assertLess(error,1e-2)
        
        A, b = five_diagonal_system(80)
        xactual = scipy_solve(A,b)
        x, n = gauss_seidel(A,b,epsilon=1e-12)
        error = norm(xactual - x)
        self.assertLess(error,1e-7)
 def scipy_solve_test():
     x = scipy_solve(A, b)
 def test_gauss(self):
     A, b = five_diagonal_system(3)
     xactual = scipy_solve(A,b)
     x, n = gauss_seidel(A,b)
     error = norm(xactual - x)
     self.assertLess(error,1e-8)      
 def test_jacobi(self):
     A, b = five_diagonal_system(3)
     xactual = scipy_solve(A,b)
     x, n = jacobi(A,b)
     error = norm(xactual - x)
     self.assertLess(error,1e-8)