Here you can find the source of normalizeVector(double[] input)
public static void normalizeVector(double[] input)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.j a v a 2 s .c om*/ * This method normalizes the input vector to 1. */ public static void normalizeVector(double[] input) { int index = 0; double sum = 0; while (index < input.length) { sum += input[index]; index++; } index = 0; while (index < input.length) { input[index] = input[index] / sum; index++; } } }