Java Array Max Value maxAbs(double[] a, int begin, int end)

Here you can find the source of maxAbs(double[] a, int begin, int end)

Description

max Abs

License

Open Source License

Declaration

public final static double maxAbs(double[] a, int begin, int end) 

Method Source Code

//package com.java2s;
/*//  w  w w. java2  s  . c om
 *  Util.java
 *  This file is part of AcMus.
 *  
 *  AcMus: Tools for Measurement, Analysis, and Simulation of Room Acoustics
 *  
 *  Copyright (C) 2006 Leo Ueda, Bruno Masiero
 *  
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

public class Main {
    public final static double maxAbs(double[] a, int begin, int end) {
        double max = Math.abs(a[begin]);
        for (int i = begin + 1; i < end; i++) {
            if (Math.abs(a[i]) > max) {
                max = Math.abs(a[i]);
            }
        }
        return max;
    }

    public final static double maxAbs(double[] a) {
        return maxAbs(a, 0, a.length);
    }

    public static int maxAbs(int[] data) {
        int max = 0;
        for (int i = 0; i < data.length; ++i) {
            if (Math.abs(data[i]) > max) {
                max = Math.abs(data[i]);
            }
        }
        return max;
    }
}

Related

  1. max(T[] args)
  2. max_array(byte[] arr)
  3. max_index(int[] v)
  4. max_of_ints(int[] data)
  5. max_val_subsequence(int[] vals)
  6. maxAbs(float[] a, int off, int length)
  7. maxarr(double[] a)
  8. maxArray(double[] input)
  9. maxArray(int[] arr)