speed-up t_invmod() subroutine