Inverse problem approach to the design of magnetic field pulses for precessional switching