示例#1
0
        protected int VectorDataComparer(VectorData a, VectorData b)
        {
            if (a.vectorScore > b.vectorScore)
            {
                return(1);
            }
            else if (a.vectorScore < b.vectorScore)
            {
                return(-1);
            }

            return(0);
        }
示例#2
0
        public void SortData(VectorData target)
        {
            if (m_SourceDataList.Count == 0)
            {
                return;
            }

            for (int i = m_SourceDataList.Count - 1; i >= 0; --i)
            {
                float score = SqrMagnitude(target, m_SourceDataList[i]);
                m_SourceDataList[i].vectorScore = score;
            }

            m_SourceDataList.Sort(VectorDataComparer);
        }
示例#3
0
        public float SqrMagnitude(VectorData target, VectorData source)
        {
            float[] targetData = target.vectorRawData;
            float[] sourceData = source.vectorRawData;

            float result = 0;

            int dimension = target.vectorDimension;

            for (int i = 0; i < dimension; ++i)
            {
                m_CalculateTemp = targetData[i] - sourceData[i];

                result += m_CalculateTemp * m_CalculateTemp * m_DiamensionWeight[i];
            }

            return(result);
        }
示例#4
0
        public float SqrMagnitude2(VectorData target, VectorData source)
        {
            float[] targetData = target.vectorRawData;
            float[] sourceData = source.vectorRawData;

            float result = 0;

            int dimension = target.vectorDimension;

            for (int i = 0; i < dimension; ++i)
            {
                float p = targetData[i] / sourceData[i];
                if (p < 0.8f)
                {
                    continue;
                }
                else if (p < 1.0f)
                {
                    result += p * 100;
                }
                else if (p < 1.2f)
                {
                    result += 100 + (p - 1) * 1000;
                }
                else
                {
                    result += 200 - (p - 1.5f) * 50;
                }

                m_CalculateTemp = targetData[i] - sourceData[i];

                result += m_CalculateTemp * m_CalculateTemp * m_DiamensionWeight[i];
            }

            return(result);
        }
示例#5
0
 public void AddSourceData(VectorData data)
 {
     m_SourceDataList.Add(data);
 }