package utils.array;

public class ArraySumUtil {

	public static double sum(double[] items) {
		double total = 0;
		for (double item : items) {
			total += item;
		}
		return total;
	}
	
	public static long sum(long[] items) {
		long total = 0;
		for (long item : items) {
			total += item;
		}
		return total;
	}

	public static float sum(float[] items) {
		float total = 0;
		for (float item : items) {
			total += item;
		}
		return total;
	}

	public static long sum(int[] items) {
		long total = 0;
		for (int item : items) {
			total += item;
		}
		return total;
	}
	
//	public static float[] normalize(float[] values) {
//		float sum = sum(values);
//		for (int i = 0; i < values.length; i++) {
//			values[i] = values[i]/sum;
//		}
//		return values;
//	}
	
	public static double[] normalize(double[] array){
		double sum = sum(array);
		for(int i = 0; i < array.length; i++){
			array[i] = array[i]/sum;
		}
		return array;
	}
}

@@ -604,18 +604,16 @@
 %0A%09%7D%0D%0A%09%0D%0A
-//
 %09public 
@@ -656,18 +656,16 @@
 ues) %7B%0D%0A
-//
 %09%09float 
@@ -684,18 +684,16 @@
 lues);%0D%0A
-//
 %09%09for (i
@@ -729,18 +729,16 @@
 i++) %7B%0D%0A
-//
 %09%09%09value
@@ -764,17 +764,13 @@
 m;%0D%0A
-//
 %09%09%7D%0D%0A
-//
 %09%09re
@@ -787,10 +787,8 @@
 s;%0D%0A
-//
 %09%7D%0D%0A

add normalize method for float