Solver for the generalized Pell equation.