Java Array Max Value maxDiffLocation(double[] list1, double[] list2)

Here you can find the source of maxDiffLocation(double[] list1, double[] list2)

Description

This method finds the largest difference between numbers in the same cell of the two lists and returns the location where that difference occurs.

License

Open Source License

Parameter

Parameter Description
list1 a parameter
list2 a parameter

Return

the location of the largest difference between values from the same cell in the two lists

Declaration

public static int maxDiffLocation(double[] list1, double[] list2) 

Method Source Code

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

public class Main {
    /**//from   w w  w  .  j  ava 2  s.c  o  m
     * This method finds the largest difference between numbers in the same cell
     * of the two lists and returns the location where that difference occurs.
     * The lists must be the same size.
     * @param list1 
     * @param list2
     * @return the location of the largest difference between values from the same
     * cell in the two lists
     */
    public static int maxDiffLocation(double[] list1, double[] list2) {
        int location = 0;
        double val = (list1[location] - list2[location]);
        for (int i = 0; i < list1.length; ++i) {
            if (Math.abs(list1[i] - list2[i]) > val) {
                location = i;
                val = Math.abs(list1[i] - list2[i]);
            }
        }
        return location;
    }
}

Related

  1. maxCommonLeadingWhitespaceForAll(String[] strings)
  2. maxcount(int[] vals, int max, int maxcount)
  3. maxDblArrayValue(int npts, double[] dbls)
  4. maxdex(float... values)
  5. maxdiffbits(int initoffset, int[] i, int pos, int length)
  6. maxDistance(byte[] array, int maxDistance)
  7. maxDouble(double a, double... others)
  8. maxElement(double[] d)
  9. maxElement(int[] array)