X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=include%2Fkmath.h;h=0ed4f2a3cb3de6319d8dbd75fbfa7acbb1b2c667;hp=bb30f05d683f8caf073e37e742ef6bb5c706ed8f;hb=2c61ff85796550481227f2fbec53506a6b5bd365;hpb=f4a23943110823118f35756dd41fbd6707f04511 diff --git a/include/kmath.h b/include/kmath.h index bb30f05..0ed4f2a 100644 --- a/include/kmath.h +++ b/include/kmath.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: kmath.h,v 1.14 2000/06/17 20:12:14 kevin Exp $ +** $Id: kmath.h,v 1.15 2000/06/18 10:27:11 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -68,6 +68,18 @@ template inline T lineLength (T x1, T y1, T x2, T y2) { return static_cast( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); } +template +inline void minmax_array (const T* array, const int n, T& min, T& max) +{ + max = min = array[0]; + + for (int i = 1; i < n; i++) + if (array[i] < min) + min = array[i]; + else if (array[i] > max) + max = array[i]; +} + /* clip.cpp */ int clip_rect(double *x1, double *y1, double *x2, double *y2, const double rect[4]); int clip_segment(double *x1, double *y1, double *x2, double *y2, const double u, const double v); @@ -92,8 +104,4 @@ void scale2d(double x[], double y[], int pts, double xfact, double yfact); /* simpson.cpp */ double simpson(const double xmin, const double xmax, const double *y, const int np); -/* minmax.cpp */ -void minmax_dvector(const double array[], const int pts, double *xmin, double *xmax); - - #endif