The R Project SVN R

Rev

Rev 60071 | Rev 68947 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 60071 Rev 60079
Line 25... Line 25...
25
 
25
 
26
#include <R_ext/Applic.h>
26
#include <R_ext/Applic.h>
27
#include <R_ext/Boolean.h>
27
#include <R_ext/Boolean.h>
28
#include <R_ext/Utils.h>
28
#include <R_ext/Utils.h>
29
 
29
 
30
/* This is called from bvalue() and others in ../library/modreg/src/ : */
30
/* This is called from stats/src/bvalue.f, and packages gam and mda */
31
int F77_SUB(interv)(double *xt, int *n, double *x,
31
int F77_SUB(interv)(double *xt, int *n, double *x,
32
		    Rboolean *rightmost_closed, Rboolean *all_inside,
32
		    Rboolean *rightmost_closed, Rboolean *all_inside,
33
		    int *ilo, int *mflag)
33
		    int *ilo, int *mflag)
34
{
34
{
35
  return findInterval(xt, *n, *x, *rightmost_closed, *all_inside, *ilo, mflag);
35
  return findInterval(xt, *n, *x, *rightmost_closed, *all_inside, *ilo, mflag);
36
}
36
}
37
 
37
 
38
/* This one to be called from R {via .C(..)} :
-
 
39
   FIXME: Replace by a .Call()able version!
-
 
40
 
-
 
41
   Done for R 2.15.2, no longer used in R, but used in IBDsim and timeSeries
-
 
42
 */
-
 
43
void find_interv_vec(double *xt, int *n,	double *x,  int *nx,
-
 
44
		     int *rightmost_closed, int *all_inside, int *indx)
-
 
45
{
-
 
46
    int i, ii, mfl;
-
 
47
    ii = 1;
-
 
48
    for(i=0; i < *nx; i++) {
-
 
49
	mfl = *all_inside;
-
 
50
	ii = findInterval(xt, *n, x[i],
-
 
51
			  *rightmost_closed, *all_inside, ii,  &mfl);
-
 
52
	indx[i] = ii;
-
 
53
    }
-
 
54
}
-
 
55
 
-
 
56
int findInterval(double *xt, int n, double x,
38
int findInterval(double *xt, int n, double x,
57
		  Rboolean rightmost_closed,  Rboolean all_inside, int ilo,
39
		  Rboolean rightmost_closed,  Rboolean all_inside, int ilo,
58
		  int *mflag)
40
		  int *mflag)
59
{
41
{
60
    int istep, middle, ihi;
42
    int istep, middle, ihi;