Canoe
Comprehensive Atmosphere N' Ocean Engine
locate.c
Go to the documentation of this file.
1
7
int
locate
(
double
const
*xx,
double
x,
int
n) {
8
xx -= 1;
// zero-offset to unit-offset
9
10
int
j
;
11
int
ju, jm, jl;
12
int
ascnd;
13
14
jl = 0;
15
ju = n + 1;
16
ascnd = (xx[n] >= xx[1]);
17
while
(ju - jl > 1) {
18
jm = (ju + jl) >> 1;
19
if
(x >= xx[jm] == ascnd)
20
jl = jm;
21
else
22
ju = jm;
23
}
24
if
(x == xx[1])
25
j
= 1;
26
else
if
(x == xx[n])
27
j
= n - 1;
28
else
29
j
= jl;
30
31
j
-= 1;
// unit-offset to zero-offset
32
return
j
;
33
}
locate
int locate(double const *xx, double x, int n)
Definition:
locate.c:7
make_plots.j
j
Definition:
make_plots.py:26
src
climath
locate.c
Generated by
1.9.1