add implementation of lrCostFunction.