1 /* statistics/minmax_source.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Jim Davies, Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 FUNCTION (gsl_stats,max) (const BASE data[], const size_t stride,
25 /* finds the largest member of a dataset */
27 BASE max = data[0 * stride];
30 for (i = 0; i < n; i++)
32 BASE xi = data[i * stride];
46 FUNCTION (gsl_stats,min) (const BASE data[], const size_t stride,
49 /* finds the smallest member of a dataset */
51 BASE min = data[0 * stride];
54 for (i = 0; i < n; i++)
56 BASE xi = data[i * stride];
71 FUNCTION (gsl_stats,minmax) (BASE * min_out, BASE * max_out,
72 const BASE data[], const size_t stride,
75 /* finds the smallest and largest members of a dataset */
77 BASE min = data[0 * stride];
78 BASE max = data[0 * stride];
81 for (i = 0; i < n; i++)
83 BASE xi = data[i * stride];
107 FUNCTION (gsl_stats,max_index) (const BASE data[], const size_t stride,
110 /* finds the index of the largest member of a dataset */
111 /* if there is more than one largest value then we choose the first */
113 BASE max = data[0 * stride];
114 size_t i, max_index = 0;
116 for (i = 0; i < n; i++)
118 BASE xi = data[i * stride];
138 FUNCTION (gsl_stats,min_index) (const BASE data[], const size_t stride,
141 /* finds the index of the smallest member of a dataset */
142 /* if there is more than one largest value then we choose the first */
144 BASE min = data[0 * stride];
145 size_t i, min_index = 0;
147 for (i = 0; i < n; i++)
149 BASE xi = data[i * stride];
169 FUNCTION (gsl_stats,minmax_index) (size_t * min_index_out,
170 size_t * max_index_out, const BASE data[],
171 const size_t stride, const size_t n)
173 /* finds the smallest and largest members of a dataset */
175 BASE min = data[0 * stride];
176 BASE max = data[0 * stride];
177 size_t i, min_index = 0, max_index = 0;
179 for (i = 0; i < n; i++)
181 BASE xi = data[i * stride];
205 *min_index_out = min_index;
206 *max_index_out = max_index;