MINT2
Public Member Functions | Protected Attributes | Friends | List of all members
HyperPoint Class Reference

#include <HyperPoint.h>

Inheritance diagram for HyperPoint:
Weights

Public Member Functions

 HyperPoint (int dimension)
 
 HyperPoint (int dimension, double val)
 
 HyperPoint (std::vector< double > coords)
 
 HyperPoint (double x1)
 
 HyperPoint (double x1, double x2)
 
 HyperPoint (double x1, double x2, double x3)
 
 HyperPoint (double x1, double x2, double x3, double x4)
 
 HyperPoint (double x1, double x2, double x3, double x4, double x5)
 
 HyperPoint (double x1, double x2, double x3, double x4, double x5, double x6)
 
 HyperPoint (double x1, double x2, double x3, double x4, double x5, double x6, double x7)
 
const std::vector< double > & getVector ()
 
HyperPoint linearTransformation (const TMatrixD &matrix)
 
virtual void print (std::ostream &os=std::cout, int endline=1) const
 
const double & at (int i) const
 
double & at (int i)
 
HyperPointoperator= (const HyperPoint &other)
 
HyperPoint operator+ (const HyperPoint &other) const
 
HyperPoint operator- (const HyperPoint &other) const
 
HyperPoint operator- (const double &other) const
 
HyperPoint operator+ (const double &other) const
 
HyperPoint operator/ (const double &other) const
 
HyperPoint operator * (const double &other) const
 
bool operator< (const HyperPoint &other) const
 
bool operator > (const HyperPoint &other) const
 
bool operator<= (const HyperPoint &other) const
 
bool operator >= (const HyperPoint &other) const
 
bool operator== (const HyperPoint &other) const
 
bool operator != (const HyperPoint &other) const
 
bool allLT (const HyperPoint &other) const
 
bool allGT (const HyperPoint &other) const
 
bool allLTOE (const HyperPoint &other) const
 
bool allGTOE (const HyperPoint &other) const
 
bool operator< (const double &other) const
 
bool operator > (const double &other) const
 
bool operator<= (const double &other) const
 
bool operator >= (const double &other) const
 
bool operator== (const double &other) const
 
double multiplyElements () const
 
double dotProduct (const HyperPoint &other) const
 
void fillRandom (double min=-1.0, double max=1.0)
 
HyperPoint project (const HyperPoint &other) const
 
double distanceTo (const HyperPoint &other) const
 
double norm () const
 
double norm2 () const
 
int size () const
 
int getDimension () const
 
bool compatible (const HyperPoint &other, bool printError=true) const
 
 ~HyperPoint ()
 
- Public Member Functions inherited from Weights
 Weights ()
 
 Weights (double weight)
 
int numWeights () const
 
const std::vector< double > & getWeightsVector ()
 
void printWeight (std::ostream &os=std::cout, int endline=1) const
 
double getWeight (int i=0) const
 
void setWeight (int i, double w)
 
void setWeight (double w)
 
void addWeight (const double &weight)
 
virtual ~Weights ()
 

Protected Attributes

std::vector< double > _coords
 
- Protected Attributes inherited from Weights
std::vector< double > _weights
 

Friends

std::ostream & operator<< (std::ostream &os, const HyperPoint &point)
 

Detailed Description

HyperPlot, Author: Sam Harnew, sam.h.nosp@m.arne.nosp@m.w@gma.nosp@m.il.c.nosp@m.om , Date: Dec 2015

A point in multi-dimensional space

Definition at line 26 of file HyperPoint.h.

Constructor & Destructor Documentation

◆ HyperPoint() [1/10]

HyperPoint::HyperPoint ( int  dimension)

Most basic constructor that makes a HyperPoint with a specified dimension, and filled with 0.0 for each element.

Definition at line 6 of file HyperPoint.cpp.

6  :
7  _coords(dimension, 0.0)
8 {
9 }
std::vector< double > _coords
Definition: HyperPoint.h:30

◆ HyperPoint() [2/10]

HyperPoint::HyperPoint ( int  dimension,
double  val 
)

Constructor that makes a HyperPoint with a specified dimension, and fills each element with a specified value.

Definition at line 14 of file HyperPoint.cpp.

14  :
15  _coords(dimension, val)
16 {
17 }
std::vector< double > _coords
Definition: HyperPoint.h:30

◆ HyperPoint() [3/10]

HyperPoint::HyperPoint ( std::vector< double >  coords)

Constuctor that takes a std::vector of elements

Definition at line 21 of file HyperPoint.cpp.

21  :
22  _coords(coords)
23 {
24 }
std::vector< double > _coords
Definition: HyperPoint.h:30

◆ HyperPoint() [4/10]

HyperPoint::HyperPoint ( double  x1)

Constuctor for a 1D space.

Definition at line 28 of file HyperPoint.cpp.

28  :
29  _coords(1, 0.0)
30 {
31  at(0) = x1;
32 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [5/10]

HyperPoint::HyperPoint ( double  x1,
double  x2 
)

Constuctor for a 2D space.

Definition at line 36 of file HyperPoint.cpp.

36  :
37  _coords(2, 0.0)
38 {
39  at(0) = x1;
40  at(1) = x2;
41 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [6/10]

HyperPoint::HyperPoint ( double  x1,
double  x2,
double  x3 
)

Constuctor for a 3D space.

Definition at line 45 of file HyperPoint.cpp.

45  :
46  _coords(3, 0.0)
47 {
48  at(0) = x1;
49  at(1) = x2;
50  at(2) = x3;
51 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [7/10]

HyperPoint::HyperPoint ( double  x1,
double  x2,
double  x3,
double  x4 
)

Constuctor for a 4D space.

Definition at line 55 of file HyperPoint.cpp.

55  :
56  _coords(4, 0.0)
57 {
58  at(0) = x1;
59  at(1) = x2;
60  at(2) = x3;
61  at(3) = x4;
62 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [8/10]

HyperPoint::HyperPoint ( double  x1,
double  x2,
double  x3,
double  x4,
double  x5 
)

Constuctor for a 5D space.

Definition at line 66 of file HyperPoint.cpp.

66  :
67  _coords(5, 0.0)
68 {
69  at(0) = x1;
70  at(1) = x2;
71  at(2) = x3;
72  at(3) = x4;
73  at(4) = x5;
74 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [9/10]

HyperPoint::HyperPoint ( double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6 
)

Definition at line 76 of file HyperPoint.cpp.

76  :
77  _coords(6, 0.0)
78 {
79  at(0) = x1;
80  at(1) = x2;
81  at(2) = x3;
82  at(3) = x4;
83  at(4) = x5;
84  at(5) = x6;
85 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ HyperPoint() [10/10]

HyperPoint::HyperPoint ( double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7 
)

Definition at line 87 of file HyperPoint.cpp.

87  :
88  _coords(7, 0.0)
89 {
90  at(0) = x1;
91  at(1) = x2;
92  at(2) = x3;
93  at(3) = x4;
94  at(4) = x5;
95  at(5) = x6;
96  at(6) = x7;
97 }
std::vector< double > _coords
Definition: HyperPoint.h:30
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ ~HyperPoint()

HyperPoint::~HyperPoint ( )

Destructor

Definition at line 478 of file HyperPoint.cpp.

478  {
479 }

Member Function Documentation

◆ allGT()

bool HyperPoint::allGT ( const HyperPoint other) const

Checks if every element of v2 is greater than the

same element in v2. i.e. v1_0 > v2_0 && v1_1 > v2_1 && ...

Definition at line 347 of file HyperPoint.cpp.

347  {
348  if (this->compatible(other) == 0) return false;
349 
350  for (int i = 0; i < size(); i++) {
351  if (this->at(i) <= other.at(i)) return false;
352  }
353  return true;
354 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ allGTOE()

bool HyperPoint::allGTOE ( const HyperPoint other) const

Checks if every element of v1 is greater than or equal to the

same element in v2. i.e. v1_0 >= v2_0 && v1_1 >= v2_1 && ...

Definition at line 369 of file HyperPoint.cpp.

369  {
370  if (this->compatible(other) == 0) return false;
371 
372  for (int i = 0; i < size(); i++) {
373  if (this->at(i) < other.at(i)) return false;
374  }
375  return true;
376 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ allLT()

bool HyperPoint::allLT ( const HyperPoint other) const

Checks if every element of v1 is less than the

same element in v2. i.e. v1_0 < v2_0 && v1_1 < v2_1 && ...

Definition at line 336 of file HyperPoint.cpp.

336  {
337  if (this->compatible(other) == 0) return false;
338 
339  for (int i = 0; i < size(); i++) {
340  if (this->at(i) >= other.at(i)) return false;
341  }
342  return true;
343 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ allLTOE()

bool HyperPoint::allLTOE ( const HyperPoint other) const

Checks if every element of v1 is less than or equal to the

same element in v2. i.e. v1_0 <= v2_0 && v1_1 <= v2_1 && ...

Definition at line 358 of file HyperPoint.cpp.

358  {
359  if (this->compatible(other) == 0) return false;
360 
361  for (int i = 0; i < size(); i++) {
362  if (this->at(i) > other.at(i)) return false;
363  }
364  return true;
365 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ at() [1/2]

const double & HyperPoint::at ( int  i) const

returns a const reference to a choosen element of the HyperPoint. Can be used for getting the value, but not setting

Definition at line 433 of file HyperPoint.cpp.

433  {
434  if (i >= this->size()) {
435  ERROR_LOG << "The component of this HyperPoint you have selected is out of range";
436  return _coords.at(this->size() - 1);
437  }
438  return _coords.at(i);
439 }
int size() const
Definition: HyperPoint.h:96
#define ERROR_LOG
std::vector< double > _coords
Definition: HyperPoint.h:30

◆ at() [2/2]

double & HyperPoint::at ( int  i)

returns a reference to a choosen element of the HyperPoint. Can be used for getting or setting it's value.

Definition at line 443 of file HyperPoint.cpp.

443  {
444  if (i >= size()) {
445  ERROR_LOG << "The component of this HyperPoint you have selected is out of range";
446  return _coords.at(size() - 1);
447  }
448  return _coords.at(i);
449 }
int size() const
Definition: HyperPoint.h:96
#define ERROR_LOG
std::vector< double > _coords
Definition: HyperPoint.h:30

◆ compatible()

bool HyperPoint::compatible ( const HyperPoint other,
bool  printError = true 
) const

Check if two HyperPoints are compatible (of the same dimension)

Definition at line 111 of file HyperPoint.cpp.

111  {
112 
113  if (getDimension() != other.getDimension()) {
114  if (printError == true) ERROR_LOG << "HyperPoints are of different dimension i.e. not compatible!!!";
115  return 0;
116  }
117  return 1;
118 
119 }
#define ERROR_LOG
int getDimension() const
Definition: HyperPoint.h:99

◆ distanceTo()

double HyperPoint::distanceTo ( const HyperPoint other) const

Find the distance between this point and another

Definition at line 123 of file HyperPoint.cpp.

123  {
124  if (this->compatible(other) == 0) return 0.0;
125  HyperPoint temp = other - *this;
126  return temp.norm();
127 }
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
double norm() const
Definition: HyperPoint.cpp:131

◆ dotProduct()

double HyperPoint::dotProduct ( const HyperPoint other) const

Find the dot product of two points

Definition at line 147 of file HyperPoint.cpp.

147  {
148  if (this->compatible(other) == 0) return 0.0;
149 
150  double val = 0.0;
151  for (int i = 0; i < size(); i++) val += at(i)*other.at(i);
152  return val;
153 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ fillRandom()

void HyperPoint::fillRandom ( double  min = -1.0,
double  max = 1.0 
)

Fill the point with random numbers, uniformly distributed between min and max. Uses gRandom for random number.

Definition at line 157 of file HyperPoint.cpp.

157  {
158 
159  for(int i = 0; i < size(); i++) at(i) = gRandom->Uniform(min,max);
160 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ getDimension()

int HyperPoint::getDimension ( ) const
inline

get the dimensionality of the HyperPoint

Definition at line 99 of file HyperPoint.h.

◆ getVector()

const std::vector<double>& HyperPoint::getVector ( )
inline

Get the std::vector<double> that contains the coordinates

Definition at line 48 of file HyperPoint.h.

◆ linearTransformation()

HyperPoint HyperPoint::linearTransformation ( const TMatrixD &  matrix)

Perform a linear transformation on the HyperPoint using a specified matrix. v_new = v_old M

Leave weights unchanged.

Definition at line 266 of file HyperPoint.cpp.

266  {
267 
268  HyperPoint point(getDimension());
269 
270  for (int i = 0; i < getDimension(); i++){
271  double val = 0.0;
272  for (int j = 0; j < getDimension(); j++){
273  val += at(j)*matrix(i,j);
274  }
275  point.at(i) = val;
276  }
277 
278  return point;
279 
280 }
const double & at(int i) const
Definition: HyperPoint.cpp:433
int getDimension() const
Definition: HyperPoint.h:99

◆ multiplyElements()

double HyperPoint::multiplyElements ( ) const

Multiply all the elements together.

Definition at line 103 of file HyperPoint.cpp.

103  {
104  double total = 1.0;
105  for (int i = 0; i < size(); i++) total *= this->at(i);
106  return total;
107 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ norm()

double HyperPoint::norm ( ) const

Find the norm = sqrt(x1^2 + x2^2 + ...)

Definition at line 131 of file HyperPoint.cpp.

131  {
132  double normVal = 0.0;
133  for (int i = 0; i < size(); i++) normVal += at(i)*at(i);
134  return sqrt(normVal);
135 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ norm2()

double HyperPoint::norm2 ( ) const

Find the norm squared =(x1^2 + x2^2 + ...)

Definition at line 139 of file HyperPoint.cpp.

139  {
140  double normVal = 0.0;
141  for (int i = 0; i < size(); i++) normVal += at(i)*at(i);
142  return normVal;
143 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator !=()

bool HyperPoint::operator != ( const HyperPoint other) const

Checks if two HyperPoints are not identical

Definition at line 389 of file HyperPoint.cpp.

389  {
390  if (this->compatible(other) == 0) return false;
391 
392  for (int i = 0; i < size(); i++) if (this->at(i) != other.at(i)) return true;
393  return false;
394 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator *()

HyperPoint HyperPoint::operator * ( const double &  other) const

Multiply all elements of a HyperPoint by one value. Leave weights unchanged.

Definition at line 253 of file HyperPoint.cpp.

253  {
254 
255  HyperPoint temp(size());
256 
257  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) * other;
258 
259  return temp;
260 
261 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator >() [1/2]

bool HyperPoint::operator > ( const HyperPoint other) const

Compare two HyperPoints. First compares 0th element of each HyperPoint, if these are the same, compares the next, etc.

Definition at line 298 of file HyperPoint.cpp.

298  {
299  if (this->compatible(other) == 0) return false;
300 
301  for (int i = 0; i < size(); i++) {
302  if (this->at(i) < other.at(i)) return false;
303  if (this->at(i) > other.at(i)) return true;
304  }
305  return false;
306 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator >() [2/2]

bool HyperPoint::operator > ( const double &  other) const

Checks if all elements of a HyperPoint are greater than a given value

Definition at line 405 of file HyperPoint.cpp.

405  {
406  for (int i = 0; i < size(); i++) if ((this->at(i) > other)==0) return false;
407  return true;
408 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator >=() [1/2]

bool HyperPoint::operator >= ( const HyperPoint other) const

Compare two HyperPoints. First compares 0th element of each HyperPoint, if these are the same, compares the next, etc.

Definition at line 324 of file HyperPoint.cpp.

324  {
325  if (this->compatible(other) == 0) return false;
326 
327  for (int i = 0; i < size(); i++) {
328  if (this->at(i) < other.at(i)) return false;
329  if (this->at(i) > other.at(i)) return true;
330  }
331  return true;
332 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator >=() [2/2]

bool HyperPoint::operator >= ( const double &  other) const

Checks if all elements of a HyperPoint are greater than or equal to a given value

Definition at line 419 of file HyperPoint.cpp.

419  {
420  for (int i = 0; i < size(); i++) if ((this->at(i) >= other)==0) return false;
421  return true;
422 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator+() [1/2]

HyperPoint HyperPoint::operator+ ( const HyperPoint other) const

Add elements of two HyperPoints together - leave weights unchanged.

Definition at line 189 of file HyperPoint.cpp.

189  {
190 
191  if (this->compatible(other) == 0) return *this;
192 
193  HyperPoint temp(size());
194 
195  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) + other.at(i);
196 
197  return temp;
198 
199 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator+() [2/2]

HyperPoint HyperPoint::operator+ ( const double &  other) const

Add one value to all elements of the HyperPoint. Leave weights unchanged.

Definition at line 229 of file HyperPoint.cpp.

229  {
230 
231  HyperPoint temp(size());
232 
233  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) + other;
234 
235  return temp;
236 
237 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator-() [1/2]

HyperPoint HyperPoint::operator- ( const HyperPoint other) const

Subtract one HyperPoint from another - leave weights unchanged.

Definition at line 203 of file HyperPoint.cpp.

203  {
204 
205  if (this->compatible(other) == 0) return *this;
206 
207  HyperPoint temp(size());
208 
209  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) - other.at(i);
210 
211  return temp;
212 
213 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator-() [2/2]

HyperPoint HyperPoint::operator- ( const double &  other) const

Subtract one value from all elements of the HyperPoint. Leave weights unchanged.

Definition at line 217 of file HyperPoint.cpp.

217  {
218 
219  HyperPoint temp(size());
220 
221  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) - other;
222 
223  return temp;
224 
225 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator/()

HyperPoint HyperPoint::operator/ ( const double &  other) const

Divide all elements of a HyperPoint by one value. Leave weights unchanged.

Definition at line 241 of file HyperPoint.cpp.

241  {
242 
243  HyperPoint temp(size());
244 
245  for (int i = 0; i < size(); i++) temp.at(i) = this->at(i) / other;
246 
247  return temp;
248 
249 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator<() [1/2]

bool HyperPoint::operator< ( const HyperPoint other) const

Perform a linear transformation on the HyperPoint using a specified matrix. v_new = v_old M

Leave weights unchanged.

Definition at line 285 of file HyperPoint.cpp.

285  {
286  if (this->compatible(other) == 0) return false;
287 
288  for (int i = 0; i < size(); i++) {
289  if (this->at(i) < other.at(i)) return true;
290  if (this->at(i) > other.at(i)) return false;
291  }
292  return false;
293 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator<() [2/2]

bool HyperPoint::operator< ( const double &  other) const

Checks if all elements of a HyperPoint are smaller than a given value

Definition at line 398 of file HyperPoint.cpp.

398  {
399  for (int i = 0; i < size(); i++) if ((this->at(i) < other)==0) return false;
400  return true;
401 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator<=() [1/2]

bool HyperPoint::operator<= ( const HyperPoint other) const

Compare two HyperPoints. First compares 0th element of each HyperPoint, if these are the same, compares the next, etc.

Definition at line 311 of file HyperPoint.cpp.

311  {
312  if (this->compatible(other) == 0) return false;
313 
314  for (int i = 0; i < size(); i++) {
315  if (this->at(i) < other.at(i)) return true;
316  if (this->at(i) > other.at(i)) return false;
317  }
318  return true;
319 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator<=() [2/2]

bool HyperPoint::operator<= ( const double &  other) const

Checks if all elements of a HyperPoint are smaller than or equal to a given value

Definition at line 412 of file HyperPoint.cpp.

412  {
413  for (int i = 0; i < size(); i++) if ((this->at(i) <= other)==0) return false;
414  return true;
415 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator=()

HyperPoint & HyperPoint::operator= ( const HyperPoint other)

Copy all elements and weights from other HyperPoint to this. Only function that allows the dimensionality of a point to be changed after it is created. Should be careful with this, for instance a HyperPointSet only accepts HyperPoint's of the same dimension. If you change the dimensionality of a point after it has been added, this could cause big problems.

Definition at line 178 of file HyperPoint.cpp.

178  {
179  //if (this->compatible(other) == 0) return *this;
180 
181  _coords = other._coords;
182  _weights = other._weights;
183 
184  return *this;
185 }
std::vector< double > _coords
Definition: HyperPoint.h:30
std::vector< double > _weights
Definition: Weights.h:27

◆ operator==() [1/2]

bool HyperPoint::operator== ( const HyperPoint other) const

Checks if two HyperPoints are identical

Definition at line 380 of file HyperPoint.cpp.

380  {
381  if (this->compatible(other) == 0) return false;
382 
383  for (int i = 0; i < size(); i++) if (this->at(i) != other.at(i)) return false;
384  return true;
385 }
int size() const
Definition: HyperPoint.h:96
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ operator==() [2/2]

bool HyperPoint::operator== ( const double &  other) const

Checks if all elements of a HyperPoint are equal to a given value

Definition at line 426 of file HyperPoint.cpp.

426  {
427  for (int i = 0; i < size(); i++) if ((this->at(i) == other)==0) return false;
428  return true;
429 }
int size() const
Definition: HyperPoint.h:96
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ print()

void HyperPoint::print ( std::ostream &  os = std::cout,
int  endline = 1 
) const
virtual

Print the HyperPoint to the given std::ostream (default is std::cout).

Definition at line 453 of file HyperPoint.cpp.

453  {
454 
455  std::ostringstream oss;
456 
457  oss << "( ";
458  for(int i = 0; i < (size() - 1); i++){
459  oss << std::setw(10) << std::left << _coords.at(i) << ", ";
460  }
461  if (size() != 0) oss << std::setw(10) << std::left << _coords.at(size() - 1);
462  oss << ")";
463 
464  this->printWeight(oss, 0);
465 
466  if (endline) oss << std::endl;
467 
468  os << oss.str();
469 }
int size() const
Definition: HyperPoint.h:96
std::vector< double > _coords
Definition: HyperPoint.h:30
void printWeight(std::ostream &os=std::cout, int endline=1) const
Definition: Weights.cpp:26

◆ project()

HyperPoint HyperPoint::project ( const HyperPoint other) const

Project this vector onto another = v1 (v1.v2/v1.v1)

Definition at line 164 of file HyperPoint.cpp.

164  {
165  if (this->compatible(other) == 0) return *this;
166 
167  HyperPoint projection(*this);
168  double scale = this->dotProduct(other) / this->dotProduct(*this);
169  return (projection * scale);
170 }
double dotProduct(const HyperPoint &other) const
Definition: HyperPoint.cpp:147
bool compatible(const HyperPoint &other, bool printError=true) const
Definition: HyperPoint.cpp:111

◆ size()

int HyperPoint::size ( ) const
inline

get the dimensionality of the HyperPoint

Definition at line 96 of file HyperPoint.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const HyperPoint point 
)
friend

Definition at line 471 of file HyperPoint.cpp.

471  {
472  point.print(os, 0);
473  return os;
474 }
virtual void print(std::ostream &os=std::cout, int endline=1) const
Definition: HyperPoint.cpp:453

Member Data Documentation

◆ _coords

std::vector<double> HyperPoint::_coords
protected

The coordinates of the point in muli-dimensional spave

Definition at line 30 of file HyperPoint.h.


The documentation for this class was generated from the following files: