Numerical solution of the direct scattering problem for the nonlinear Schrödinger equation