Generalized Krylov subspace methods with applications