Java Array Absolute Value absMax(double[] vector)

Here you can find the source of absMax(double[] vector)

Description

abs Max

License

Open Source License

Return

the value that differs most from zero

Declaration

private static double absMax(double[] vector) 

Method Source Code

//package com.java2s;
/**//from w w  w. j av  a 2  s . c o  m
 * Copyright (c) 2011 Michael Kutschke.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Michael Kutschke - initial API and implementation.
 */

public class Main {
    /**
     * 
     * @return the value that differs most from zero
     */
    private static double absMax(double[] vector) {
        double result = 0;
        for (double d : vector) {
            if (d != Double.NEGATIVE_INFINITY && Math.abs(d) > Math.abs(result)) {
                result = d;
            }
        }
        return result;
    }
}

Related

  1. absAvg(double[] inputArray, int divisions, int cap)
  2. absDiff(Double[] a, Double[] b)
  3. absMax(double x, double y)
  4. absMax(double[] arr)
  5. absMax(double[] data)
  6. absMean(double[] arr)
  7. absMean(double[] x)
  8. absolulteValue(float[][] image)