1 /* matrix/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_matrix, max) (const TYPE (gsl_matrix) * m)
23 /* finds the largest element of a matrix */
25 const size_t M = m->size1;
26 const size_t N = m->size2;
27 const size_t tda = m->tda;
29 BASE max = m->data[0 * tda + 0];
32 for (i = 0; i < M; i++)
34 for (j = 0; j < N; j++)
36 BASE x = m->data[i * tda + j];
50 FUNCTION (gsl_matrix, min) (const TYPE (gsl_matrix) * m)
52 /* finds the smallest element of a matrix */
54 const size_t M = m->size1;
55 const size_t N = m->size2;
56 const size_t tda = m->tda;
58 BASE min = m->data[0 * tda + 0];
61 for (i = 0; i < M; i++)
63 for (j = 0; j < N; j++)
65 BASE x = m->data[i * tda + j];
80 FUNCTION (gsl_matrix, minmax) (const TYPE (gsl_matrix) * m,
84 /* finds the smallest and largest elements of a matrix */
86 const size_t M = m->size1;
87 const size_t N = m->size2;
88 const size_t tda = m->tda;
90 BASE max = m->data[0 * tda + 0];
91 BASE min = m->data[0 * tda + 0];
95 for (i = 0; i < M; i++)
97 for (j = 0; j < N; j++)
99 BASE x = m->data[i * tda + j];
124 FUNCTION (gsl_matrix, max_index) (const TYPE (gsl_matrix) * m, size_t * imax_out, size_t *jmax_out)
126 /* finds the largest element of a matrix */
128 const size_t M = m->size1;
129 const size_t N = m->size2;
130 const size_t tda = m->tda;
132 BASE max = m->data[0 * tda + 0];
133 size_t imax = 0, jmax = 0;
136 for (i = 0; i < M; i++)
138 for (j = 0; j < N; j++)
140 BASE x = m->data[i * tda + j];
163 FUNCTION (gsl_matrix, min_index) (const TYPE (gsl_matrix) * m, size_t * imin_out, size_t *jmin_out)
165 /* finds the largest element of a matrix */
167 const size_t M = m->size1;
168 const size_t N = m->size2;
169 const size_t tda = m->tda;
171 BASE min = m->data[0 * tda + 0];
172 size_t imin = 0, jmin = 0;
175 for (i = 0; i < M; i++)
177 for (j = 0; j < N; j++)
179 BASE x = m->data[i * tda + j];
202 FUNCTION (gsl_matrix, minmax_index) (const TYPE (gsl_matrix) * m,
208 /* finds the smallest and largest elements of a matrix */
210 const size_t M = m->size1;
211 const size_t N = m->size2;
212 const size_t tda = m->tda;
214 size_t imin = 0, jmin = 0, imax = 0, jmax = 0;
215 BASE max = m->data[0 * tda + 0];
216 BASE min = m->data[0 * tda + 0];
220 for (i = 0; i < M; i++)
222 for (j = 0; j < N; j++)
224 BASE x = m->data[i * tda + j];