Exemple #1
0
        /// <summary>
        /// Euclidean distance squared.
        /// </summary>
        public static double Dist2Squared(Floatarray a, Floatarray b)
        {
            if (!a.SameDims(b))
            {
                throw new Exception("Dist2Squared: !a.SameDims(b)");
            }
            double total = 0.0;

            for (int i = 0; i < a.Length1d(); i++)
            {
                float val = a.At1d(i) - b.At1d(i);
                total += val * val;
            }
            if (double.IsNaN(total))
            {
                throw new Exception("Dist2Squared: total is NaN !");
            }
            return(total);
        }