## 生成三角矩阵

### 稀疏矩阵的写法：

spdiags函数：Extract and create sparse band and diagonal matrices


B = spdiags(A)


[B,d] = spdiags(A）


B = spdiags(A,d)


A = spdiags(B,d,A)


Replaces the diagonals specified by d with the columns of B.
The output is sparse.

A = spdiags(B,d,m,n)


Roughly, A, B, and d are related by

## Sherman-Morrison formula

${(B+{uv}^{T})}^{-1} = {B}^{-1}-\frac{ {B}^{-1}{uv}^{T}{B}^{-1}}{1+{v}^{T}{B}^{-1}u}$