Java Array Absolute Value absAvg(double[] inputArray, int divisions, int cap)

Here you can find the source of absAvg(double[] inputArray, int divisions, int cap)

Description

abs Avg

License

Open Source License

Declaration

public static double absAvg(double[] inputArray, int divisions, int cap) 

Method Source Code

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

public class Main {
    public static double absAvg(double[] inputArray, int divisions, int cap) {
        double result = 0;
        int count = inputArray.length;
        if (count > cap) {
            double[][] parts = new double[count][];
            for (int i = 0; i < divisions; i++) {
                int start = (count * i) / divisions;
                int end = (count * (i + 1)) / divisions;
                int length = end - start;
                parts[i] = new double[length];
                for (int j = 0; j < length; j++) {
                    parts[i][j] = inputArray[j + start];
                }/*from w  w w  .  ja  va  2s.c  om*/
                result += absAvg(parts[i], divisions, cap);
            }
            result /= divisions;
        } else {
            for (double i : inputArray) {
                result += Math.abs(i);
            }
            result /= count;
        }
        //System.out.println(result);
        return result;
    }
}

Related

  1. abs_sum(int[] data)
  2. absDiff(Double[] a, Double[] b)
  3. absMax(double x, double y)
  4. absMax(double[] arr)
  5. absMax(double[] data)