BICO  1.0
 All Classes Namespaces Files Functions Variables Typedefs Pages
point.h
Go to the documentation of this file.
1 #ifndef POINT_H
2 #define POINT_H
3 
4 #include <iostream>
5 #include <vector>
6 
7 #include "../base/weightedobject.h"
8 
9 namespace CluE
10 {
11 
17 class Point : public WeightedObject
18 {
19 public:
23  Point(size_t dimension = 0, double pointWeight = 1.0):coordinates(std::vector<double>(dimension)),weight(pointWeight)
24  {
25  }
26 
30  Point(std::vector<double> coords, double pointWeight = 1.0):coordinates(coords),weight(pointWeight)
31  {
32  }
33 
38  Point(std::vector<Point*> const&);
39 
44  {
45  }
46 
47  virtual ~Point()
48  {
49  }
50 
54  Point& operator+=(Point const & x);
55 
59  Point& operator-=(Point const & x);
60 
64  Point operator+(Point const & x) const;
65 
69  Point operator-(Point const & x) const;
70 
74  double& operator[](size_t index)
75  {
76  return this->coordinates[index];
77  }
78 
82  double operator[](size_t index) const
83  {
84  return this->coordinates[index];
85  }
86 
87  size_t dimension() const
88  {
89  return this->coordinates.size();
90  }
91 
92  virtual double getWeight() const
93  {
94  return this->weight;
95  }
96 
97  virtual void setWeight(double w)
98  {
99  this->weight = w;
100  }
101 
105  double squaredL1distance(Point const&) const;
106 
110  double l1distance(Point const&) const;
111 
115  double squaredL2distance(Point const&) const;
116 
120  double l2distance(Point const&) const;
121 
125  double lpdistance(Point const&, double p) const;
126 
130  double squaredLpDistance(Point const&, double p) const;
131 
136  double kullbackleibler(Point const&) const;
137 
138 private:
139  std::vector<double> coordinates;
140  double weight;
141 };
142 
143 std::ostream& operator<<(std::ostream&, Point const&);
144 
145 Point operator*(double scalar, Point const & vec);
146 
150 double operator*(Point const & vec1, Point const & vec2);
151 
152 }
153 
154 #endif