Java List Max maxAbsVal(List vals)

Here you can find the source of maxAbsVal(List vals)

Description

Get the maximum absolute value

License

Open Source License

Declaration


public static double maxAbsVal(List vals) 

Method Source Code

//package com.java2s;
/*//w  ww.j a  va  2 s  .c o m
**    Copyright (C) 2003-2018 Institute for Systems Biology 
**                            Seattle, Washington, USA. 
**
**    This library is free software; you can redistribute it and/or
**    modify it under the terms of the GNU Lesser General Public
**    License as published by the Free Software Foundation; either
**    version 2.1 of the License, or (at your option) any later version.
**
**    This library 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
**    Lesser General Public License for more details.
**
**    You should have received a copy of the GNU Lesser General Public
**    License along with this library; if not, write to the Free Software
**    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.util.List;

public class Main {
    /***************************************************************************
    **
    ** Get the maximum absolute value
    */

    public static double maxAbsVal(List vals) {
        int num = vals.size();
        double maxVal = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < num; i++) {
            Double val0bj = (Double) vals.get(i);
            if (val0bj.isNaN()) {
                return (val0bj.doubleValue());
            }
            double val = Math.abs(val0bj.doubleValue());
            if (val > maxVal) {
                maxVal = val;
            }
        }
        return ((maxVal == Double.NEGATIVE_INFINITY) ? Double.NaN : maxVal);
    }
}

Related

  1. max(List runtimeList)
  2. max(List numberList)
  3. max(List numbers)
  4. max(List objectList)
  5. max(List arg)
  6. maxIndex( List list)
  7. maxIndex(List list)
  8. maxInnerSize(List> listOfLists)
  9. maxInt(List array)