Computation of the direct scattering transform for the nonlinear Schroedinger equation