private int NeighborhoodDistance(IntVector fillPercentageRef, IntVector fillPercentage)
        {
            if (fillPercentageRef == null || fillPercentage == null || !fillPercentageRef.Any() || !fillPercentage.Any())
            {
                return -1;

            }
            if (fillPercentageRef.Count() != fillPercentage.Count())
            {
                return -1;
            }
            var total = 0;
            for (int pIndexor = 0; pIndexor < fillPercentageRef.Count(); pIndexor++)
            {
                var diff = Math.Abs(fillPercentageRef[pIndexor] - fillPercentage[pIndexor]);
                total += diff * diff;
            }
            return total;
        }
예제 #2
0
파일: IntVector.cs 프로젝트: yukseljunk/wps
        public int DotProduct(IntVector otherIntVector)
        {
            if (this.Count() != otherIntVector.Count())
            {
                throw new ArgumentException("vectors need to have equal elements!");
            }
            if (!this.Any()) return 0;

            var result = 0;
            for (int posCounter = 0; posCounter < _items.Count; posCounter++)
            {
                result += _items[posCounter] * otherIntVector[posCounter];
            }
            return result;
        }
예제 #3
0
파일: IntVector.cs 프로젝트: yukseljunk/wps
 public double NormalizedProduct(IntVector otherIntVector)
 {
     if (this.Count() != otherIntVector.Count())
     {
         throw new ArgumentException("vectors need to have equal elements!");
     }
     if (!this.Any()) return 0;
     var dotProduct = this.DotProduct(otherIntVector);
     var magnitudeProduct = this.Magnitude() * otherIntVector.Magnitude();
     if (magnitudeProduct == 0) return 0;
     return (double)dotProduct / magnitudeProduct;
 }