linear_algebra.src.gaussian_elimination_pivoting

Attributes

example_matrix

Functions

solve_linear_system(→ numpy.ndarray)

Solve a linear system of equations using Gaussian elimination with partial pivoting

Module Contents

linear_algebra.src.gaussian_elimination_pivoting.solve_linear_system(matrix: numpy.ndarray) numpy.ndarray

Solve a linear system of equations using Gaussian elimination with partial pivoting

Args: - matrix: Coefficient matrix with the last column representing the constants.

Returns: - Solution vector.

Raises: - ValueError: If the matrix is not correct (i.e., singular).

https://courses.engr.illinois.edu/cs357/su2013/lect.htm Lecture 7

Example: >>> A = np.array([[2, 1, -1], [-3, -1, 2], [-2, 1, 2]], dtype=float) >>> B = np.array([8, -11, -3], dtype=float) >>> solution = solve_linear_system(np.column_stack((A, B))) >>> np.allclose(solution, np.array([2., 3., -1.])) True >>> solve_linear_system(np.array([[0, 0], [0, 0]], dtype=float)) array([nan, nan])

linear_algebra.src.gaussian_elimination_pivoting.example_matrix