When setting up the algo it is useful to note that the different operations on the matrix (here as a \( 4\times 4 \) case with diagonals \( d_i \) and off-diagonals \( e_i \)) give is an extremely simple algorithm, namely $$ \begin{bmatrix} d_1 & e_1 & 0 & 0 \\ e_2 & d_2 & e_2 & 0 \\ 0 & e_3 & d_3 & e_3 \\ 0 & 0 & e_4 & d_4 \end{bmatrix}\rightarrow \begin{bmatrix} d_1 & e_1 & 0 & 0 \\ 0 & \tilde{d}_2 & e_2 & 0 \\ 0 & e_3 & d_3 & e_3 \\ 0 & 0 & e_4 & d_4 \end{bmatrix}\rightarrow \begin{bmatrix} d_1 & e_1 & 0 & 0 \\ 0 & \tilde{d}_2 & e_2 & 0 \\ 0 & 0 & \tilde{d}_3 & e_3 \\ 0 & 0 & e_4 & d_4 \end{bmatrix} $$ and finally $$ \begin{bmatrix} d_1 & e_1 & 0 & 0 \\ 0 & \tilde{d}_2 & e_2 & 0 \\ 0 & 0 & \tilde{d}_3 & e_3 \\ 0 & 0 & 0 & \tilde{d}_4 \end{bmatrix} $$