Java Array Max Value maxAbs(float[] a, int off, int length)

Here you can find the source of maxAbs(float[] a, int off, int length)

Description

max Abs

License

Open Source License

Declaration

public static float maxAbs(float[] a, int off, int length) 

Method Source Code

//package com.java2s;
/*//from   w  w w  .ja va2  s.  co  m
 *  Util.java
 *  (FScape)
 *
 *  Copyright (c) 2001-2015 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU General Public License v3+
 *
 *
 *   For further information, please contact Hanns Holger Rutz at
 *   contact@sciss.de
 *
 *
 *  Changelog:
 *      17-Jun-07   extended
 */

public class Main {
    public static float maxAbs(float[] a, int off, int length) {
        final int stop = off + length;
        float f1 = 0f, f2;
        while (off < stop) {
            f2 = Math.abs(a[off++]);
            if (f2 > f1)
                f1 = f2;
        }
        return f1;
    }

    public static float maxAbs(float[][] a, int off, int length) {
        final int stop = off + length;
        float f1 = 0f, f2;
        float[] b;

        for (int i = 0; i < a.length; i++) {
            b = a[i];
            for (int j = off; j < stop; j++) {
                f2 = Math.abs(b[j]);
                if (f2 > f1)
                    f1 = f2;
            }
        }
        return f1;
    }
}

Related

  1. max_array(byte[] arr)
  2. max_index(int[] v)
  3. max_of_ints(int[] data)
  4. max_val_subsequence(int[] vals)
  5. maxAbs(double[] a, int begin, int end)
  6. maxarr(double[] a)
  7. maxArray(double[] input)
  8. maxArray(int[] arr)
  9. maxBetween(int[] arr1, int[] arr2)