Here you can find the source of min(double[] array)
public static double min(double[] array)
//package com.java2s; /*/*from w w w. j a v a 2s . c om*/ * Java Information Dynamics Toolkit (JIDT) * Copyright (C) 2012, Joseph T. Lizier * * 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 3 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, see <http://www.gnu.org/licenses/>. */ public class Main { public static double min(double[][] matrix) { // double min = 0.0; double min = matrix[0][0]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (Double.isNaN(min) || (matrix[i][j] < min)) { min = matrix[i][j]; } } } return min; } public static int min(int[][] matrix) { // int min = 0; int min = matrix[0][0]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (matrix[i][j] < min) { min = matrix[i][j]; } } } return min; } public static double min(double[] array) { return minStartFromIndex(array, 0); } public static int min(int[] array) { // int min = 0; int min = array[0]; for (int i = 0; i < array.length; i++) { if (array[i] < min) { min = array[i]; } } return min; } /** * Works out the minimum value in the matrix in a given column * * @param matrix * @param column * @return */ public static double min(double[][] matrix, int column) { // double min = 0.0; // Allow ArrayIndexOutOfBoundsException if matrix is size 0 double min = matrix[0][column]; for (int i = 1; i < matrix.length; i++) { if (Double.isNaN(min) || (matrix[i][column] < min)) { min = matrix[i][column]; } } return min; } /** * Works out the minimum value in the matrix in a given column * * @param matrix * @param column * @return */ public static int min(int[][] matrix, int column) { // double min = 0.0; // Allow ArrayIndexOutOfBoundsException if matrix is size 0 int min = matrix[0][column]; for (int i = 1; i < matrix.length; i++) { if (matrix[i][column] < min) { min = matrix[i][column]; } } return min; } public static double minStartFromIndex(double[] array, int startFromIndex) { // double min = 0.0; double min = array[startFromIndex]; for (int i = startFromIndex; i < array.length; i++) { if (Double.isNaN(min) || (array[i] < min)) { min = array[i]; } } return min; } }