#include "Point.h" #include #include #include "util/check.hh" #include #include "FeatureStats.h" using namespace std; vector Point::optindices; unsigned Point::dim = 0; map Point::fixedweights; unsigned Point::pdim = 0; unsigned Point::ncall = 0; vector Point::m_min; vector Point::m_max; Point::Point() : vector(dim), score_(0.0) {} //Can initialize from a vector of dim or pdim Point::Point(const vector& init, const vector& min, const vector& max) : vector(Point::dim), score_(0.0) { m_min.resize(Point::dim); m_max.resize(Point::dim); if(init.size()==dim) { for (unsigned int i=0; i::iterator it=fixedweights.begin(); it!=fixedweights.end(); it++) prod+=it->second*F.get(it->first); } return prod; } Point Point::operator+(const Point& p2) const { CHECK(p2.size() == size()); Point Res(*this); for (unsigned i = 0; i < size(); i++) { Res[i] += p2[i]; } Res.score_ = numeric_limits::max(); return Res; } void Point::operator+=(const Point& p2) { CHECK(p2.size() == size()); for (unsigned i = 0; i < size(); i++) { operator[](i) += p2[i]; } score_ = numeric_limits::max(); } Point Point::operator*(float l) const { Point Res(*this); for (unsigned i = 0; i < size(); i++) { Res[i] *= l; } Res.score_ = numeric_limits::max(); return Res; } ostream& operator<<(ostream& o, const Point& P) { vector w = P.GetAllWeights(); for (unsigned int i = 0; i < Point::pdim; i++) { o << w[i] << " "; } return o; } void Point::NormalizeL2() { parameter_t norm=0.0; for (unsigned int i=0; i Point::GetAllWeights()const { vector w; if(OptimizeAll()) { w=*this; } else { w.resize(pdim); for (unsigned int i=0; i::iterator it=fixedweights.begin(); it!=fixedweights.end(); it++) w[it->first]=it->second; } return w; }