1 /* vector/minmax_source.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, 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.
21 FUNCTION(gsl_vector,max) (const TYPE(gsl_vector) * v)
23 /* finds the largest element of a vector */
25 const size_t N = v->size ;
26 const size_t stride = v->stride ;
28 BASE max = v->data[0 * stride];
31 for (i = 0; i < N; i++)
33 BASE x = v->data[i*stride];
46 FUNCTION(gsl_vector,min) (const TYPE(gsl_vector) * v)
48 /* finds the smallest element of a vector */
50 const size_t N = v->size ;
51 const size_t stride = v->stride ;
53 BASE min = v->data[0 * stride];
56 for (i = 0; i < N; i++)
58 BASE x = v->data[i*stride];
71 FUNCTION(gsl_vector,minmax) (const TYPE(gsl_vector) * v,
75 /* finds the smallest and largest elements of a vector */
77 const size_t N = v->size ;
78 const size_t stride = v->stride ;
80 BASE max = v->data[0 * stride];
81 BASE min = v->data[0 * stride];
85 for (i = 0; i < N; i++)
87 BASE x = v->data[i*stride];
112 FUNCTION(gsl_vector,max_index) (const TYPE(gsl_vector) * v)
114 /* finds the largest element of a vector */
116 const size_t N = v->size ;
117 const size_t stride = v->stride ;
119 BASE max = v->data[0 * stride];
123 for (i = 0; i < N; i++)
125 BASE x = v->data[i*stride];
143 FUNCTION(gsl_vector,min_index) (const TYPE(gsl_vector) * v)
145 /* finds the smallest element of a vector */
147 const size_t N = v->size ;
148 const size_t stride = v->stride ;
150 BASE min = v->data[0 * stride];
154 for (i = 0; i < N; i++)
156 BASE x = v->data[i*stride];
175 FUNCTION(gsl_vector,minmax_index) (const TYPE(gsl_vector) * v,
179 /* finds the smallest and largest elements of a vector */
181 const size_t N = v->size ;
182 const size_t stride = v->stride ;
184 size_t imin = 0, imax = 0;
185 BASE max = v->data[0 * stride];
186 BASE min = v->data[0 * stride];
190 for (i = 0; i < N; i++)
192 BASE x = v->data[i*stride];