matrix element code using on pre-calculated grids