Java Array Min Value min(double[] da)

Here you can find the source of min(double[] da)

Description

Returns the minimum value in vector of doubles.

License

Open Source License

Parameter

Parameter Description
da - input vector of doubles.

Return

- the minimum value within the vector.

Declaration


public static double min(double[] da) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  ww. j a v a  2 s . co  m*/
     * Returns the minimum value in vector of doubles.
     * @param da - input vector of doubles.
     * @return - the minimum value within the vector.
     */

    public static double min(double[] da) {
        if (da.length == 0) {
            return Double.NaN;
        }
        double out = Double.POSITIVE_INFINITY;
        for (int i = 0; i < da.length; i++) {
            out = Math.min(out, da[i]);
        }
        return out;
    }

    /**
     * @param da - a vector of double values.
     * @param val - the comparison value.
     * @return the minimum value between an array of doubles and a given value.
     */

    public static double min(double[] da, double val) {
        double out = val;
        for (int i = 0; i < da.length; i++) {
            out = Math.min(out, da[i]);
        }
        return out;
    }
}

Related

  1. min(double[] array)
  2. min(double[] array)
  3. min(double[] array)
  4. min(double[] array)
  5. min(double[] array)
  6. min(double[] data)
  7. min(double[] matrix)
  8. min(double[] numbers)
  9. min(double[] series)