diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-03-20 15:37:54 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-03-20 15:37:54 -0400 |
commit | 34b4752a1eefc002166e95782c2c52747bb08b3a (patch) | |
tree | 0045687d1de1d539cd232ba4e71940e9baee72c0 /dpmert | |
parent | 0b598b997a7c1d2d9dc255cc2ff1bf9bb2c425a1 (diff) |
make c++11 compatible
Diffstat (limited to 'dpmert')
-rw-r--r-- | dpmert/ces.cc | 3 | ||||
-rw-r--r-- | dpmert/lo_test.cc | 13 | ||||
-rw-r--r-- | dpmert/mert_geometry.cc | 15 |
3 files changed, 14 insertions, 17 deletions
diff --git a/dpmert/ces.cc b/dpmert/ces.cc index a85454da..c6cb1cdf 100644 --- a/dpmert/ces.cc +++ b/dpmert/ces.cc @@ -11,7 +11,6 @@ #include "error_surface.h" #include "ns.h" -using boost::shared_ptr; using namespace std; const bool minimize_segments = true; // if adjacent segments have equal scores, merge them @@ -22,7 +21,7 @@ void ComputeErrorSurface(const SegmentEvaluator& ss, const EvaluationMetric* metric, const Hypergraph& hg) { vector<WordID> prev_trans; - const vector<shared_ptr<MERTPoint> >& ienv = ve.GetSortedSegs(); + const vector<boost::shared_ptr<MERTPoint> >& ienv = ve.GetSortedSegs(); env->resize(ienv.size()); SufficientStats prev_score; // defaults to 0 int j = 0; diff --git a/dpmert/lo_test.cc b/dpmert/lo_test.cc index d9b909b8..5d90aabb 100644 --- a/dpmert/lo_test.cc +++ b/dpmert/lo_test.cc @@ -19,7 +19,6 @@ #include "line_optimizer.h" using namespace std; -using boost::shared_ptr; class OptTest : public testing::Test { protected: @@ -44,12 +43,12 @@ TEST_F(OptTest, TestCheckNaN) { } TEST_F(OptTest,TestConvexHull) { - shared_ptr<MERTPoint> a1(new MERTPoint(-1, 0)); - shared_ptr<MERTPoint> b1(new MERTPoint(1, 0)); - shared_ptr<MERTPoint> a2(new MERTPoint(-1, 1)); - shared_ptr<MERTPoint> b2(new MERTPoint(1, -1)); - vector<shared_ptr<MERTPoint> > sa; sa.push_back(a1); sa.push_back(b1); - vector<shared_ptr<MERTPoint> > sb; sb.push_back(a2); sb.push_back(b2); + boost::shared_ptr<MERTPoint> a1(new MERTPoint(-1, 0)); + boost::shared_ptr<MERTPoint> b1(new MERTPoint(1, 0)); + boost::shared_ptr<MERTPoint> a2(new MERTPoint(-1, 1)); + boost::shared_ptr<MERTPoint> b2(new MERTPoint(1, -1)); + vector<boost::shared_ptr<MERTPoint> > sa; sa.push_back(a1); sa.push_back(b1); + vector<boost::shared_ptr<MERTPoint> > sb; sb.push_back(a2); sb.push_back(b2); ConvexHull a(sa); cerr << a << endl; ConvexHull b(sb); diff --git a/dpmert/mert_geometry.cc b/dpmert/mert_geometry.cc index 81b25af9..d6973658 100644 --- a/dpmert/mert_geometry.cc +++ b/dpmert/mert_geometry.cc @@ -4,13 +4,12 @@ #include <limits> using namespace std; -using boost::shared_ptr; ConvexHull::ConvexHull(int i) { if (i == 0) { // do nothing - <> } else if (i == 1) { - points.push_back(shared_ptr<MERTPoint>(new MERTPoint(0, 0, 0, shared_ptr<MERTPoint>(), shared_ptr<MERTPoint>()))); + points.push_back(boost::shared_ptr<MERTPoint>(new MERTPoint(0, 0, 0, boost::shared_ptr<MERTPoint>(), boost::shared_ptr<MERTPoint>()))); assert(this->IsMultiplicativeIdentity()); } else { cerr << "Only can create ConvexHull semiring 0 and 1 with this constructor!\n"; @@ -27,7 +26,7 @@ const ConvexHull ConvexHullWeightFunction::operator()(const Hypergraph::Edge& e) ostream& operator<<(ostream& os, const ConvexHull& env) { os << '<'; - const vector<shared_ptr<MERTPoint> >& points = env.GetSortedSegs(); + const vector<boost::shared_ptr<MERTPoint> >& points = env.GetSortedSegs(); for (int i = 0; i < points.size(); ++i) os << (i==0 ? "" : "|") << "x=" << points[i]->x << ",b=" << points[i]->b << ",m=" << points[i]->m << ",p1=" << points[i]->p1 << ",p2=" << points[i]->p2; return os << '>'; @@ -37,7 +36,7 @@ ostream& operator<<(ostream& os, const ConvexHull& env) { #ifdef ORIGINAL_MERT_IMPLEMENTATION struct SlopeCompare { - bool operator() (const shared_ptr<MERTPoint>& a, const shared_ptr<MERTPoint>& b) const { + bool operator() (const boost::shared_ptr<MERTPoint>& a, const boost::shared_ptr<MERTPoint>& b) const { return a->m < b->m; } }; @@ -93,7 +92,7 @@ const ConvexHull& ConvexHull::operator*=(const ConvexHull& other) { if (this->IsEdgeEnvelope()) { // if (other.size() > 1) // cerr << *this << " (TIMES) " << other << endl; - shared_ptr<MERTPoint> edge_parent = points[0]; + boost::shared_ptr<MERTPoint> edge_parent = points[0]; const double& edge_b = edge_parent->b; const double& edge_m = edge_parent->m; points.clear(); @@ -102,13 +101,13 @@ const ConvexHull& ConvexHull::operator*=(const ConvexHull& other) { const double m = p.m + edge_m; const double b = p.b + edge_b; const double& x = p.x; // x's don't change with * - points.push_back(shared_ptr<MERTPoint>(new MERTPoint(x, m, b, edge_parent, other.points[i]))); + points.push_back(boost::shared_ptr<MERTPoint>(new MERTPoint(x, m, b, edge_parent, other.points[i]))); assert(points.back()->p1->edge); } // if (other.size() > 1) // cerr << " = " << *this << endl; } else { - vector<shared_ptr<MERTPoint> > new_points; + vector<boost::shared_ptr<MERTPoint> > new_points; int this_i = 0; int other_i = 0; const int this_size = points.size(); @@ -124,7 +123,7 @@ const ConvexHull& ConvexHull::operator*=(const ConvexHull& other) { const double m = this_point.m + other_point.m; const double b = this_point.b + other_point.b; - new_points.push_back(shared_ptr<MERTPoint>(new MERTPoint(cur_x, m, b, points[this_i], other.points[other_i]))); + new_points.push_back(boost::shared_ptr<MERTPoint>(new MERTPoint(cur_x, m, b, points[this_i], other.points[other_i]))); int comp = 0; if (this_next_val < other_next_val) comp = -1; else if (this_next_val > other_next_val) comp = 1; |