YAMP.Numerics.BlasL1.dNrm2 C# (CSharp) Method

dNrm2() public static method

Returns |x| = sqrt( sum_i x_i^2 ) norm.
public static dNrm2 ( double store, int offset, int stride, int count ) : double
store double The source vector.
offset int The offset in the source.
stride int The offset between two elements.
count int The number of elements to consider.
return double
        public static double dNrm2(double[] store, int offset, int stride, int count)
        {
            double m = 0.0;
            int n = 0;
            int i = offset;

            while (n < count)
            {
                double x = store[i];
                m += x * x;
                n++;
                i += stride;
            }

            return Math.Sqrt(m);
        }