private double NormalizedProduct(IntVector fillPercentageRef, IntVector fillPercentage)
 {
     if (fillPercentageRef == null || fillPercentage == null || !fillPercentageRef.Any() || !fillPercentage.Any())
     {
         return -1;
     }
     return fillPercentageRef.NormalizedProduct(fillPercentage);
 }
Example #2
0
        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;
        }
        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;
        }
Example #4
0
 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;
 }