#include <R.h>
#include <Rmath.h>
#include <Rdefines.h>
#include "internal.h"
Go to the source code of this file.
◆ get_covariate_names()
SEXP get_covariate_names |
( |
SEXP |
object | ) |
|
Definition at line 7 of file lookup_table.c.
7 {
8 return GET_ROWNAMES(GET_DIMNAMES(GET_SLOT(object,install("table"))));
9}
◆ lookup_in_table()
SEXP lookup_in_table |
( |
SEXP |
covar, |
|
|
SEXP |
t |
|
) |
| |
Definition at line 24 of file lookup_table.c.
24 {
25 int xdim[2], nvar;
26 int j, nt;
27 double *tp, *xp;
29
30 PROTECT(t = AS_NUMERIC(t));
31 nt = LENGTH(t);
33
35
36 if (nt > 1) {
37 xdim[0] = nvar; xdim[1] = nt;
40 } else {
41 PROTECT(
X = NEW_NUMERIC(nvar));
43 }
44
45 for (j = 0, tp = REAL(t), xp = REAL(
X); j < nt; j++, tp++, xp += nvar)
47
48 UNPROTECT(3);
50}
void table_lookup(lookup_table_t *tab, double x, double *y)
lookup_table_t make_covariate_table(SEXP object, int *ncovar)
SEXP get_covariate_names(SEXP object)
static R_INLINE void setrownames(SEXP x, SEXP names, int rank)
static R_INLINE SEXP makearray(int rank, const int *dim)
◆ make_covariate_table()
Definition at line 11 of file lookup_table.c.
11 {
13 int *dim;
14 dim = INTEGER(GET_DIM(GET_SLOT(object,install("table"))));
15 *ncovar = tab.
width = dim[0];
18 tab.
x = REAL(GET_SLOT(
object,install(
"times")));
19 tab.
y = REAL(GET_SLOT(
object,install(
"table")));
20 tab.
order = *(INTEGER(GET_SLOT(
object,install(
"order"))));
21 return tab;
22}
◆ table_lookup()
Definition at line 53 of file lookup_table.c.
54{
55 int flag = 0;
56 int j, k, n;
57 double e;
58 if ((tab == 0) || (tab->
length < 1) || (tab->
width < 1))
return;
60
61 if ((x < tab->x[0]) || (x > tab->
x[tab->
length-1]))
62 warn(
"in 'table_lookup': extrapolating at %le.", x);
64 case 1: default:
67 y[j] = e*(tab->
y[k])+(1-e)*(tab->
y[n]);
68 }
69 break;
70 case 0:
71 if (flag < 0) n = 0;
72 else if (flag > 0) n = tab->
index;
73 else n = tab->
index-1;
74 for (j = 0, k = n*tab->
width; j < tab->
width; j++, k++) {
76 }
77 break;
78 }
79}