From a1cf0d10fe44ede32d29be37107884b734d459ae Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Sat, 11 Jan 2014 21:02:04 -0800 Subject: Fix compilation with ancient gcc --- training/crf/mpi_adagrad_optimize.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'training/crf/mpi_adagrad_optimize.cc') diff --git a/training/crf/mpi_adagrad_optimize.cc b/training/crf/mpi_adagrad_optimize.cc index 39bd763e..bac57324 100644 --- a/training/crf/mpi_adagrad_optimize.cc +++ b/training/crf/mpi_adagrad_optimize.cc @@ -157,11 +157,11 @@ struct TrainingObserver : public DecoderObserver { void GetGradient(SparseVector* g) const { g->clear(); -#if HAVE_CXX11 +#if HAVE_CXX11 && (__GNUC_MINOR__ > 4 || __GNUC__ > 4) for (auto& gi : acc_grad) { #else for (FastSparseVector::const_iterator it = acc_grad.begin(); it != acc_grad.end(); ++it) { - pair& gi = *it; + const pair& gi = *it; #endif g->set_value(gi.first, -gi.second.as_float()); } @@ -190,7 +190,7 @@ class AdaGradOptimizer { G() {} void update(const SparseVector& g, vector* x, SparseVector* sx) { if (x->size() > G.size()) G.resize(x->size(), 0.0); -#if HAVE_CXX11 +#if HAVE_CXX11 && (__GNUC_MINOR__ > 4 || __GNUC__ > 4) for (auto& gi : g) { #else for (SparseVector::const_iterator it = g.begin(); it != g.end(); ++it) { @@ -220,7 +220,7 @@ class AdaGradL1Optimizer { G.resize(x->size(), 0.0); u.resize(x->size(), 0.0); } -#if HAVE_CXX11 +#if HAVE_CXX11 && (__GNUC_MINOR__ > 4 || __GNUC__ > 4) for (auto& gi : g) { #else for (SparseVector::const_iterator it = g.begin(); it != g.end(); ++it) { @@ -236,11 +236,11 @@ class AdaGradL1Optimizer { // compute updates (avoid invalidating iterators by putting them all // in the vector vupdate and applying them after this) vector> vupdate; -#if HAVE_CXX11 +#if HAVE_CXX11 && (__GNUC_MINOR__ > 4 || __GNUC__ > 4) for (auto& xi : *sx) { #else - for (SparseVector::const_iterator it = sx->begin(); it != sx->end(); ++it) { - const pair& gi = *it; + for (SparseVector::iterator it = sx->begin(); it != sx->end(); ++it) { + const pair& xi = *it; #endif double z = fabs(u[xi.first] / t) - lambda; double s = 1; -- cgit v1.2.3