Пример #1
0
    bool Clustering::operator==(const Clustering::Point &lhs, const Clustering::Point &rhs) {
        bool ans =  false;
        if(lhs.__dim != rhs.__dim)
            throw Clustering::DimensionalityMismatchEx(lhs.__dim,rhs.__dim);

        if(lhs.getId() == rhs.getId()) {
            if (lhs.getDims() == rhs.getDims()) {
                ans = true;
                for (int i = 0; i < lhs.__dim; i++) {
                    if (lhs.getValue(i) != rhs.getValue(i)) {
                        ans = false;
                        return ans;
                    }
                }
            }
        }

        return ans;
    }
Пример #2
0
double Clustering::Point::distanceTo(const Clustering::Point &point) const {
    for(int temp = 0; temp < dim; temp++)
    return sqrt(pow(point.getValue(values[temp])-(point.values[temp]),2));
}