An implementation of the Levenberg-Marquardt algorithm