示例#1
0
        private TKey DistanceSquaredBetweenPoints(TKey[] a, TKey[] b)
        {
            TKey distance = typeMath.Zero;

            // Return the absolute distance bewteen 2 hyper points
            for (var dimension = 0; dimension < dimensions; dimension++)
            {
                TKey distOnThisAxis        = typeMath.Subtract(a[dimension], b[dimension]);
                TKey distOnThisAxisSquared = typeMath.Multiply(distOnThisAxis, distOnThisAxis);

                distance = typeMath.Add(distance, distOnThisAxisSquared);
            }

            return(distance);
        }