Java Array Normalize normalize(double[] array)

Here you can find the source of normalize(double[] array)

Description

normalize

License

Open Source License

Declaration

public static void normalize(double[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void normalize(double[] array) {
        double s = 0;
        double as = 0;
        for (int i = 0; i < array.length; ++i) {
            s += array[i];/*from w ww. j a v a2 s.  c  o m*/
            as += Math.abs(array[i]);
        }

        if (as > 0) {
            for (int i = 0; i < array.length; ++i) {
                array[i] /= s;
            }
        }
    }
}

Related

  1. normalize(double[] a)
  2. normalize(double[] a)
  3. normalize(double[] a)
  4. normalize(double[] ar)
  5. normalize(double[] array)
  6. normalize(double[] array)
  7. normalize(double[] bins)
  8. normalize(double[] d)
  9. normalize(double[] data)