19DataPoint::DataPoint(
double x,
double y)
21 setData(std::vector<double>(1, x), y);
24DataPoint::DataPoint(std::vector<double> x,
double y)
29DataPoint::DataPoint(DenseVector x,
double y)
31 std::vector<double> newX;
33 for (
int i = 0;
i < x.size();
i++)
41void DataPoint::setData(
const std::vector<double>& x,
double y)
47bool DataPoint::operator<(
const DataPoint& rhs)
const
49 if (this->getDimX() != rhs.getDimX())
51 throw Exception(
"DataPoint::operator<: Cannot compare data points of different dimensions");
54 for (
unsigned int i = 0;
i < this->getDimX();
i++)
56 if (x.at(
i) < rhs.getX().at(
i))
60 else if (x.at(
i) > rhs.getX().at(
i))
72double dist(
const std::vector<double> x,
const std::vector<double> y)
74 if (x.size() != y.size())
76 throw Exception(
"DataPoint::dist: Cannot measure distance between two points of different dimension");
81 for (
unsigned int i = 0;
i < x.size();
i++)
83 sum += (x.at(
i) - y.at(
i)) * (x.at(
i) - y.at(
i));
86 return std::sqrt(sum);
92double dist(
const DataPoint x,
const DataPoint y)
94 return dist(x.getX(), y.getX());
99 std::vector<double> zeros(x.getDimX(), 0);
100 DataPoint origin(zeros, 0.0);
101 double x_dist =
dist(x, origin);
102 double y_dist =
dist(y, origin);
103 return (x_dist < y_dist);
bool dist_sort(const DataPoint x, const DataPoint y)
double dist(const std::vector< double > x, const std::vector< double > y)