1 #include "../point/point.h"
3 #include "../exception/invalidargumentexception.h"
4 #include "../exception/invalidruntimeconfigurationexception.h"
16 size_t size = v.size();
21 weightSum = v[0]->weight;
22 for(
size_t i=1; i < size; ++i)
24 weightSum+=v[i]->weight;
32 for(
size_t i=0; i < size; ++i)
34 c += v[i]->weight*(*v[i])[n];
55 for(
size_t i = 0; i < d; ++i)
68 for(
size_t i = 0; i < d; ++i)
76 return Point(*
this) += x;
81 return Point(*
this) -= x;
91 for(
size_t i=0; i<d; ++i)
92 sum += fabs(p[i]-(*
this)[i]);
110 for(
unsigned int i=0; i<d; ++i)
112 double delta = p[i]-(*this)[i];
131 for(
size_t i=0; i<d; ++i)
133 double delta = p[i]-(*this)[i];
134 sum += pow(delta, exp);
137 sum = pow(sum, 1/exp);
153 std::vector<double> temp;
154 std::vector<double> sortedX;
155 std::vector<double> sortedY;
156 for(
size_t i=0; i<d; ++i)
158 double xi = (*this)[i];
159 sortedX.push_back(xi);
161 sortedY.push_back(yi);
168 temp.push_back(xi*log(r));
178 sort(temp.begin(), temp.end());
179 sort(sortedX.begin(), sortedX.end());
180 sort(sortedY.begin(), sortedY.end());
182 return accumulate(temp.begin(), temp.end(), .0)
183 -accumulate(sortedX.begin(), sortedX.end(), .0)
184 +accumulate(sortedY.begin(), sortedY.end(), .0);
191 for(
unsigned int i=0; i<d; i++)
206 for(
size_t i = 0; i < d; ++i)
207 ret[i] = scalar * vec[i];
220 for(
size_t i = 0; i<d; ++i)
221 ret += vec1[i] * vec2[i];
double l2distance(Point const &) const
Point & operator+=(Point const &x)
Point & operator-=(Point const &x)
double squaredLpDistance(Point const &, double p) const
std::vector< double > coordinates
double squaredL2distance(Point const &) const
double lpdistance(Point const &, double p) const
Point(size_t dimension=0, double pointWeight=1.0)
Constructs a weighted point.
double kullbackleibler(Point const &) const
Point operator+(Point const &x) const
double squaredL1distance(Point const &) const
Point operator*(double scalar, Point const &vec)
Weighted point of arbitrary dimension.
Indicates invalid values of arguments.
Point operator-(Point const &x) const
Indicates that a computation entered an invalid configuration state.
double l1distance(Point const &) const
std::ostream & operator<<(std::ostream &, Point const &)