Global FOM and GMRES algorithms for matrix equations