How to solve Hermitian positive-banded matrix equation using Python SciPy?


The linear function named scipy.linalg.solveh_banded is used to solve the banded matrix equation. In the below given example we will be solving the banded system Hx = b where −

$$\mathrm{H} = \begin{bmatrix} 8 & 2-1j&0 &0 \ 2+1j & 5& 1j & -2-1j0\ 0 & -1j& 9& \ 0 & 0& -2+1j& 6 \end{bmatrix} \mathrm{b}=\begin{bmatrix} 1\ 1+1j\ 1-2j\ 0 \end{bmatrix}$$

For our example below, we will be putting the upper diagonal in the array hb −

Example

from scipy.linalg import solveh_banded
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) 
print(x)

Output

array([ 0.07318536-0.02939412j, 0.11877624+0.17696461j, 0.10077984-0.23035393j, -0.00479904-0.09358128j])

Updated on: 25-Nov-2021

145 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements