Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public void AddElement(KMeanElement element)
 {
     mAllDatas.Add(element);
 }