Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static double[] normalize(double[] input) {
        double absSum = absSum(input);
        double[] normalizedResult = new double[input.length];
        for (int i = 0; i < input.length; i++) {
            normalizedResult[i] = input[i] / absSum;
        }
        return normalizedResult;
    }

    public static double absSum(double[] input) {
        double sum = 0;
        for (int i = 0; i < input.length; i++) {
            sum += Math.abs(input[i]);
        }
        return sum;
    }

    public static void abs(double[] input) {
        for (int i = 0; i < input.length; i++) {
            input[i] += Math.abs(input[i]);
        }
    }
}