final logreg cpp version