Best Option To Solve A Banded Matrix

Best option to solve a banded matrix

Solve the equation a x = b for x, assuming a is banded matrix.

The matrix a is stored in ab using the matrix diagonal ordered form:

Example of ab (shape of a is (6,6), u =1, l =2):

(l, u)(integer, integer)

Number of non-zero lower and upper diagonals

ab(l + u + 1, M) array_like

Banded matrix

b(M,) or (M, K) array_like

Right-hand side

overwrite_abbool, optional

Discard data in ab (may enhance performance)

overwrite_bbool, optional

Discard data in b (may enhance performance)

check_finitebool, optional

Whether to check that the input matrices contain only finite numbers.

Exploring the solution set of Ax = b - Matrix transformations - Linear Algebra - Khan Academy

Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.

x(M,) or (M, K) ndarray

The solution to the system a x = b.

Returned shape depends on the shape of b.


Solve the banded system a x = b, where:

There is one nonzero diagonal below the main diagonal (l = 1), and two above (u = 2). The diagonal banded form of the matrix is:

>>> fromscipy.linalgimportsolve_banded>>> ab=np.array([[0,0,-1,-1,-1],...

Best option to solve a banded matrix

[0,2,2,2,2],... [5,4,3,2,1],...

Best option to solve a banded matrix

[1,1,1,1,0]])>>> b=np.array([0,1,2,2,3])>>> x=solve_banded((1,2),ab,b)>>> xarray([-2.37288136, 3.93220339, -4. , 4.3559322 , -1.3559322 ])

Best option to solve a banded matrix