Accord.Statistics.Kernels.DynamicTimeWarping.snorm C# (CSharp) Method

snorm() private method

Projects vectors from a sequence of vectors into a hypersphere, augmenting their size in one unit and normalizing them to be unit vectors.
private snorm ( double input ) : double[]
input double A sequence of vectors.
return double[]
        private unsafe double[] snorm(double[] input)
        {
            // Get the number of vectors in the sequence
            int n = input.Length / length;

            // Create the augmented sequence projection
            double[] projection = new double[input.Length + n];

            fixed (double* source = input)
            fixed (double* result = projection)
            {
                double* src = source;
                double* dst = result;

                for (int i = 0; i < n; i++)
                {
                    double norm = alpha * alpha;

                    for (int j = 0; j < length; j++)
                        norm += src[j] * src[j];
                    norm = Math.Sqrt(norm);

                    for (int j = 0; j < length; j++, src++, dst++)
                        *dst = *src / norm;

                    *(dst++) = alpha / norm;
                }
            }

            return projection; // return the projected sequence
        }