HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FindInterval.c
Go to the documentation of this file.
1 
6 #include <mathfunctions.h>
7 
20  double a,
21  double b,
22  double *x,
23  int N,
24  int *imin,
25  int *imax
26  )
27 {
28  int i;
29  *imax = -1;
30  *imin = N;
31 
32  double min_dx = x[1] - x[0];
33  for (i = 2; i < N; i++) {
34  double dx = x[i] - x[i-1];
35  if (dx < min_dx) min_dx = dx;
36  }
37  double tol = 1e-10 * min_dx;
38 
39  for (i = 0; i < N; i++) {
40  if (x[i] <= (b+tol)) *imax = i+1;
41  }
42  for (i = N-1; i > -1; i--) {
43  if (x[i] >= (a-tol)) *imin = i;
44  }
45 
46  return;
47 }
void FindInterval(double, double, double *, int, int *, int *)
Definition: FindInterval.c:19
Contains function definitions for common mathematical functions.