c++ version of SGD for logistic regression