public float Distance(KMeanElement other) { int min = mCount > other.mCount ? other.mCount : mCount; float sum = 0.0f; for (int i = 0; i < min; ++i) { float t = mDatas[i] - other.mDatas[i]; sum += t * t; } return(sum); }
private int SearchMin(KMeanElement t) { float d = float.MaxValue; int c = -1; for (int i = 0; i < mK; i++) { float tmp = t.Distance(mResults[i].mCenter); if (tmp < d) { c = i; d = tmp; } } return(c); }
private int SearchMinC(KMeanElement t, int n, ref float dist) { int c = 0; float d = t.Distance(mResults[0].mCenter); for (int i = 1; i < n; i++) { float tmp = t.Distance(mResults[i].mCenter); if (tmp < d) { c = i; d = tmp; } } dist = d; return(c); }
public void AddElement(KMeanElement element) { mAllDatas.Add(element); }