Here you can find the source of minOf(double[] da, double val)
Parameter | Description |
---|---|
da | - the array of input values. |
val | - the minimum comparison value. |
public static double[] minOf(double[] da, double val)
//package com.java2s; public class Main { /**//from w w w. ja v a 2 s . c om * @param da - the array of input values. * @param val - the minimum comparison value. * @return an array containing the minimum of the array value or the given value. */ public static double[] minOf(double[] da, double val) { double[] out = new double[da.length]; for (int i = 0; i < out.length; i++) { out[i] = Math.min(da[i], val); } return out; } /** * @param a - the first array of input values. * @param b - the second array of input values. * @return an array containing the pair-wise minimum among two arrays. */ public static double[] minOf(double[] a, double[] b) { double[] out = new double[a.length]; for (int i = 0; i < out.length; i++) { out[i] = Math.min(a[i], b[i]); } return out; } /** * 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; } }