Java Array Max Value maxIndex(double[] x, int length)

Here you can find the source of maxIndex(double[] x, int length)

Description

max Index

License

BSD License

Declaration

public static int maxIndex(double[] x, int length) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    public static int maxIndex(double[] x, int length) {
        double m = Double.NEGATIVE_INFINITY;
        int mi = -1;
        for (int i = 0; i < length; i++)
            if (x[i] > m) {
                m = x[i];//from   w w  w.j  a v a 2  s  .com
                mi = i;
            }
        return mi;
    }

    public static int maxIndex(double[] x) {
        return maxIndex(x, x.length);
    }

    public static int maxIndex(int[] x, int length) {
        int m = Integer.MIN_VALUE;
        int mi = -1;
        for (int i = 0; i < length; i++)
            if (x[i] > m) {
                m = x[i];
                mi = i;
            }
        return mi;
    }
}

Related

  1. maxIndex(double[] doubles)
  2. maxIndex(double[] doubles)
  3. maxIndex(double[] doubles, int begin, int end)
  4. maxIndex(double[] v)
  5. maxIndex(double[] value)
  6. maxIndex(final double[] a)
  7. maxIndex(final double[] values)
  8. maxIndex(float[] arr)
  9. maxIndex(float[] from, int start)