Java Array Normalize normalize2(double[] x)

Here you can find the source of normalize2(double[] x)

Description

normalize

License

BSD License

Declaration

public static void normalize2(double[] x) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    public static void normalize2(double[] x) {
        double sum = 0;
        for (int i = 0; i < x.length; i++)
            if (!Double.isNaN(x[i]))
                sum += x[i] * x[i];/*w w  w  .j a v a2  s .  com*/
        if (sum == 0)
            return;
        double f = 1.0 / Math.sqrt(sum);
        for (int i = 0; i < x.length; i++)
            if (!Double.isNaN(x[i]))
                x[i] *= f;
    }
}

Related

  1. normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale)
  2. normalize(long[] v, float[] target)
  3. normalize(Number[] array)
  4. normalize(String[] slist)
  5. normalize01(float[] array)
  6. normalize3(float[] result, float[] a)
  7. normalizeAndInvertValues(double[] values, double maxValue, double minValue)
  8. normalizeArray(double[] array)
  9. normalizeArray(double[] hist)