Solver for tridiagonal systems of equations