如何使用 Python SciPy 求解 Hermitian 正带矩阵方程?
名为scipy.linalg.solveh_banded的线性函数用于求解带状矩阵方程。在下面给出的示例中,我们将解决带状系统Hx=b其中-
$$\mathrm{H}=\begin{bmatrix}8&2-1j&0&0\\2+1j&5&1j&-2-1j0\\0&-1j&9&\\0&0&-2+1j&6\结束{bmatrix}\mathrm{b}=\begin{bmatrix}1\\1+1j\\1-2j\\0\end{bmatrix}$$
对于我们下面的示例,我们将把上对角线放在数组hb中-
示例
fromscipy.linalgimport 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)输出结果
array([ 0.07318536-0.02939412j, 0.11877624+0.17696461j, 0.10077984-0.23035393j, -0.00479904-0.09358128j])