bundles / scipy latest / scipy / linalg / _basic / solveh_banded
function
scipy.linalg._basic:solveh_banded
source: /scipy/linalg/_basic.py :894
Signature
def solveh_banded ( ab , b , overwrite_ab = False , overwrite_b = False , lower = False , check_finite = True ) Summary
Solve the equation a @ x = b for x, where a is the Hermitian positive-definite banded matrix defined by ab.
Extended Summary
Uses Thomas' Algorithm, which is more efficient than standard LU factorization, but should only be used for Hermitian positive-definite matrices.
The matrix a is stored in ab either in lower diagonal or upper diagonal ordered form:
ab[u + i - j, j] == a[i,j] (if upper form; i <= j) ab[ i - j, j] == a[i,j] (if lower form; i >= j)
Example of ab (shape of a is (6, 6), number of upper diagonals, u =2)
upper form: * * a02 a13 a24 a35 * a01 a12 a23 a34 a45 a00 a11 a22 a33 a44 a55 lower form: a00 a11 a22 a33 a44 a55 a10 a21 a32 a43 a54 * a20 a31 a42 a53 * *
Cells marked with * are not used.
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
ab: (``u`` + 1, M) array_likeBanded matrix
b: (M,) or (M, K) array_likeRight-hand side
overwrite_ab: bool, optionalDiscard data in
ab(may enhance performance)overwrite_b: bool, optionalDiscard data in
b(may enhance performance)lower: bool, optionalIs the matrix in the lower form. (Default is upper form)
check_finite: bool, optionalWhether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
Returns
x: (M,) or (M, K) ndarrayThe solution to the system
a x = b. Shape of return matches shape ofb.
Notes
In the case of a non-positive definite matrix a, the solver solve_banded may be used.
Examples
Solve the banded system ``A x = b``, where:: [ 4 2 -1 0 0 0] [1] [ 2 5 2 -1 0 0] [2] A = [-1 2 6 2 -1 0] b = [2] [ 0 -1 2 7 2 -1] [3] [ 0 0 -1 2 8 2] [3] [ 0 0 0 -1 2 9] [3]import numpy as np from scipy.linalg import solveh_banded✓
ab = np.array([[ 4, 5, 6, 7, 8, 9], [ 2, 2, 2, 2, 2, 0], [-1, -1, -1, -1, 0, 0]]) b = np.array([1, 2, 2, 3, 3, 3]) x = solveh_banded(ab, b, lower=True)✓
x
✗hb = np.array([[0, 2-1j, 1j, -2-1j], [8, 5, 9, 6 ]]) b = np.array([1, 1+1j, 1-2j, 0]) x = solveh_banded(hb, b)✓
x
✗Aliases
-
scipy.linalg.solveh_banded