Numerical integration of Hamiltonian problems by G-symplectic methods