Commit version v3 from http://www.ece.northwestern.edu/~nocedal/lbfgsb.html