imsl.linalg.lu_solve

lu_solve(a, b, transpose=False)

Solve a general system Ax = b of linear equations.

Parameters:
  • a ((N,N) array_like) – Array containing the matrix A.
  • b ((N,) array_like) – Array containing the right-hand side. Elements of this array must be convertible to the same type as array a.
  • transpose (bool, optional) – If True, solve ATx=b (if a contains entries of type float) or AHx=b (if a contains entries of type complex). Default is False.
Returns:

The solution x of the linear system Ax=b.

Return type:

*(N,) ndarray*

Notes

In a first step, this function computes the LU factorization of matrix A. Then, it finds the solution of the linear system Ax = b by solving two simpler systems, y=L1b and x=U1y.

This function creates a temporary LU() instance and calls method LU.solve() on that instance.

Examples

>>> import imsl.linalg as la
>>> a = [[1.0, 3.0, 3.0], [1.0, 3.0, 4.0], [1.0, 4.0, 3.0]]
>>> b = [1.0, 4.0, -1.0]
>>> x = la.lu_solve(a, b)
>>> print(x) 
[-2. -2. 3.]