Java Array Absolute Value absDiff(Double[] a, Double[] b)

Here you can find the source of absDiff(Double[] a, Double[] b)

Description

Compute the element-wise absolute difference between two arrays of the same length.

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Return

a new array with the element-wise difference of a and b

Declaration

public static Double[] absDiff(Double[] a, Double[] b) 

Method Source Code

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

public class Main {
    /**/*from ww w  . j  a v  a 2 s.  com*/
     * Compute the element-wise absolute difference between two arrays of the
     * same length.
     * @param a
     * @param b
     * @return a new array with the element-wise difference of a and b
     */
    public static Double[] absDiff(Double[] a, Double[] b) {
        Double[] result = new Double[a.length];

        for (int i = 0; i < a.length; i++) {
            result[i] = Math.abs(a[i] - b[i]);
        }
        ;

        return result;
    }
}

Related

  1. abs_sum(int[] data)
  2. absAvg(double[] inputArray, int divisions, int cap)
  3. absMax(double x, double y)
  4. absMax(double[] arr)
  5. absMax(double[] data)
  6. absMax(double[] vector)