18 #ifndef KMEANS_DOUBLE_VECTOR_H
19 #define KMEANS_DOUBLE_VECTOR_H
30 #ifndef KMEANS_EPSILON
31 #define KMEANS_EPSILON 2.22045e-16
34 #ifndef NUM_KMEANS_DIMENSIONS
35 #define NUM_KMEANS_DIMENSIONS 1000
94 dotSum +=
rawData[i] * otherRawData[i];
105 double score =
rawData[kv] - otherRawData[kv];
106 distance += score * score;
115 std::cout << i <<
": " <<
rawData[i] <<
"; ";
117 std::cout << std::endl;
126 double precision = 0.000001;
127 double myNorm =
norm;
128 double otherNorm = other.
norm;
129 double sumSquaredNorm = myNorm * myNorm + otherNorm * otherNorm;
130 double normDiff = myNorm - otherNorm;
132 double precisionBound1 =
134 if (precisionBound1 < precision) {
135 sqDist = sumSquaredNorm - 2.0 *
dot(other);
154 std::cout <<
"Error in KMeansDoubleVector: division by zero" << std::endl;
158 double* otherRawData = result->getRawData();
160 otherRawData[i] =
rawData[i] / val;
179 double* otherRawData = other->getRawData();
181 if (
rawData[i] != otherRawData[i]) {
#define NUM_KMEANS_DIMENSIONS
double getFastSquaredDistance(KMeansDoubleVector &other)
bool equals(Handle< KMeansDoubleVector > &other)
KMeansDoubleVector & operator/(int val)
double rawData[NUM_KMEANS_DIMENSIONS]
void setValues(std::vector< double > dataToMe)
double getSquaredDistance(KMeansDoubleVector &other)
double dot(KMeansDoubleVector &other)
KMeansDoubleVector & randomizeInPlace()
KMeansDoubleVector & operator+(KMeansDoubleVector &other)
void setDouble(int i, double val)