File: rentries.c

package info (click to toggle)
r-cran-earth 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,948 kB
  • sloc: ansic: 3,830; fortran: 894; sh: 13; makefile: 5
file content (345 lines) | stat: -rw-r--r-- 9,977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
// rentries.c: Register native routines for R.
//             The core of this routine is the function R_init_earth.

#define USING_R 1
#include "R.h"
#include "Rinternals.h" // for REALSXP etc.
#include "R_ext/Rdynload.h"
#ifndef _MSC_VER // microsoft
#ifndef bool
    typedef int bool;
#endif
#endif
#include "earth.h"

static R_NativePrimitiveArgType FreeR_t[] = {INTSXP};
static R_NativePrimitiveArgType EvalSubsetsUsingXtxR_t[] = {
    REALSXP,    // 01 double        PruneTerms[]
    REALSXP,    // 02 double        RssVec[]
    INTSXP,     // 03 const int*    pnCases
    INTSXP,     // 04 const int*    pnResp
    INTSXP,     // 05 const int*    pnMaxTerms
    REALSXP,    // 06 const double  bx[]
    REALSXP,    // 07 const double  y[]
    REALSXP     // 08 const double* pTrace
};
static R_NativePrimitiveArgType RegressR_t[] = {
    REALSXP,    // 01 double       Betas[]
    REALSXP,    // 02 double       Residuals[]
    REALSXP,    // 03 double       Rss[]
    REALSXP,    // 04 double       Diags[]
    INTSXP,     // 05 int*         pnRank
    INTSXP,     // 06 int          iPivots[]
    REALSXP,    // 07 const double x[]
    REALSXP,    // 08 const double y[]
    INTSXP,     // 09 const int*   pnCases
    INTSXP,     // 10 const int*   pnResp
    INTSXP,     // 11 int*         pnCols
    LGLSXP      // 12 const bool   UsedCols[]
};
static R_CMethodDef cEntries[] = {
  {"FreeR",                (DL_FUNC)&FreeR,                 0, FreeR_t},
  {"EvalSubsetsUsingXtxR", (DL_FUNC)&EvalSubsetsUsingXtxR,  8, EvalSubsetsUsingXtxR_t},
  {"RegressR",             (DL_FUNC)&RegressR,             12, RegressR_t},
  {NULL,                   NULL,                            0, NULL}
};
static R_CallMethodDef callEntries[] = {
  {"ForwardPassR", (DL_FUNC)&ForwardPassR, 31},
  {NULL,           NULL,                    0}
};
extern void F77_SUB(bakwrd)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *THETAB,
    int    *FIRST,
    int    *LAST,
    int    *VORDER,
    double *TOL,
    double *RSS,
    double *BOUND,
    int    *NVMAX,
    double *RESS,
    int    *IR,
    int    *NBEST,
    int    *LOPT,
    int    *IL,
    double *WK,
    int    *IWK,
    int    *IER);
extern void F77_SUB(forwrd)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *THETAB,
    int    *FIRST,
    int    *LAST,
    int    *VORDER,
    double *TOL,
    double *RSS,
    double *BOUND,
    int    *NVMAX,
    double *RESS,
    int    *IR,
    int    *NBEST,
    int    *LOPT,
    int    *IL,
    double *WK,
    int    *IWK,
    int    *IER);
extern void F77_SUB(seqrep)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *THETAB,
    int    *FIRST,
    int    *LAST,
    int    *VORDER,
    double *TOL,
    double *RSS,
    double *BOUND,
    int    *NVMAX,
    double *RESS,
    int    *IR,
    int    *NBEST,
    int    *LOPT,
    int    *IL,
    double *WK,
    int    *IWK,
    int    *IER);
void F77_SUB(xhaust)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *THETAB,
    int    *FIRST,
    int    *LAST,
    int    *VORDER,
    double *TOL,
    double *RSS,
    double *BOUND,
    int    *NVMAX,
    double *RESS,
    int    *IR,
    int    *NBEST,
    int    *LOPT,
    int    *IL,
    double *WK,
    int    *DIMWK,
    int    *IWK,
    int    *DIMIWK,
    int    *IER);
extern void F77_SUB(initr)(
    int    *NP,
    int    *NVMAX,
    int    *NBEST,
    double *BOUND,
    double *RESS,
    int    *IR,
    int    *LOPT,
    int    *IL,
    int    *VORDER,
    double *RSS,
    int    *IER);
extern void F77_SUB(sing)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *THETAB,
    double *SSERR,
    double *TOL,
    bool   *LINDEP,
    double *WORK,
    int    *IER);
extern void F77_SUB(ssleaps)(
    int    *NP,
    double *D,
    double *THETAB,
    double *SSERR,
    double *RSS,
    int    *IER);
extern void F77_SUB(tolset)(
    int    *NP,
    int    *NRBAR,
    double *D,
    double *RBAR,
    double *TOL,
    double *WORK,
    int    *IER);
void F77_SUB(makeqr)(
    int    *NP,
    int    *NN,
    double *WEIGHTS,
    double *TXMAT,
    double *YVEC,
    double *D,
    double *RBAR,
    double *THETAB,
    double *SSERR,
    int    *IER);
static R_NativePrimitiveArgType bakwrd_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NRBAR
    REALSXP,    // 03 DOUBLE  D
    REALSXP,    // 04 DOUBLE  RBAR
    REALSXP,    // 05 DOUBLE  THETAB
    INTSXP,     // 06 INTEGER FIRST
    INTSXP,     // 07 INTEGER LAST
    INTSXP,     // 08 INTEGER VORDER
    REALSXP,    // 09 DOUBLE  TOL
    REALSXP,    // 10 DOUBLE  RSS
    REALSXP,    // 11 DOUBLE  BOUND
    INTSXP,     // 12 INTEGER NVMAX
    REALSXP,    // 13 DOUBLE  RESS
    INTSXP,     // 14 INTEGER IR
    INTSXP,     // 15 INTEGER NBEST
    INTSXP,     // 16 INTEGER LOPT
    INTSXP,     // 17 INTEGER IL
    REALSXP,    // 18 DOUBLE  WK
    INTSXP,     // 19 INTEGER IWK
    INTSXP,     // 20 INTEGER IER
};
static R_NativePrimitiveArgType forwrd_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NRBAR
    REALSXP,    // 03 DOUBLE  D
    REALSXP,    // 04 DOUBLE  RBAR
    REALSXP,    // 05 DOUBLE  THETAB
    INTSXP,     // 06 INTEGER FIRST
    INTSXP,     // 07 INTEGER LAST
    INTSXP,     // 08 INTEGER VORDER
    REALSXP,    // 09 DOUBLE  TOL
    REALSXP,    // 10 DOUBLE  RSS
    REALSXP,    // 11 DOUBLE  BOUND
    INTSXP,     // 12 INTEGER NVMAX
    REALSXP,    // 13 DOUBLE  RESS
    INTSXP,     // 14 INTEGER IR
    INTSXP,     // 15 INTEGER NBEST
    INTSXP,     // 16 INTEGER LOPT
    INTSXP,     // 17 INTEGER IL
    REALSXP,    // 18 DOUBLE  WK
    INTSXP,     // 19 INTEGER IWK
    INTSXP,     // 20 INTEGER IER
};
static R_NativePrimitiveArgType seqrep_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NRBAR
    REALSXP,    // 03 DOUBLE  D
    REALSXP,    // 04 DOUBLE  RBAR
    REALSXP,    // 05 DOUBLE  THETAB
    INTSXP,     // 06 INTEGER FIRST
    INTSXP,     // 07 INTEGER LAST
    INTSXP,     // 08 INTEGER VORDER
    REALSXP,    // 09 DOUBLE  TOL
    REALSXP,    // 10 DOUBLE  RSS
    REALSXP,    // 11 DOUBLE  BOUND
    INTSXP,     // 12 INTEGER NVMAX
    REALSXP,    // 13 DOUBLE  RESS
    INTSXP,     // 14 INTEGER IR
    INTSXP,     // 15 INTEGER NBEST
    INTSXP,     // 16 INTEGER LOPT
    INTSXP,     // 17 INTEGER IL
    REALSXP,    // 18 DOUBLE  WK
    INTSXP,     // 19 INTEGER IWK
    INTSXP,     // 20 INTEGER IER
};
static R_NativePrimitiveArgType xhaust_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NRBAR
    REALSXP,    // 03 DOUBLE  D
    REALSXP,    // 04 DOUBLE  RBAR
    REALSXP,    // 05 DOUBLE  THETAB
    INTSXP,     // 06 INTEGER FIRST
    INTSXP,     // 07 INTEGER LAST
    INTSXP,     // 08 INTEGER VORDER
    REALSXP,    // 09 DOUBLE  TOL
    REALSXP,    // 10 DOUBLE  RSS
    REALSXP,    // 11 DOUBLE  BOUND
    INTSXP,     // 12 INTEGER NVMAX
    REALSXP,    // 13 DOUBLE  RESS
    INTSXP,     // 14 INTEGER IR
    INTSXP,     // 15 INTEGER NBEST
    INTSXP,     // 16 INTEGER LOPT
    INTSXP,     // 17 INTEGER IL
    REALSXP,    // 18 DOUBLE  WK
    INTSXP,     // 19 INTEGER DIMWK
    INTSXP,     // 20 INTEGER IWK
    INTSXP,     // 21 INTEGER DIMIWK
    INTSXP,     // 22 INTEGER IER
};
static R_NativePrimitiveArgType initr_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NVMAX
    INTSXP,     // 03 INTEGER NBEST
    REALSXP,    // 09 DOUBLE  BOUND
    REALSXP,    // 10 DOUBLE  RESS
    INTSXP,     // 04 INTEGER IR
    INTSXP,     // 06 INTEGER LOPT
    INTSXP,     // 05 INTEGER IL
    INTSXP,     // 07 INTEGER VORDER
    REALSXP,    // 11 DOUBLE  RSS
    INTSXP,     // 08 INTEGER IER
};
static R_NativePrimitiveArgType sing_t[] = {
    INTSXP,     // 01 DOUBLE  NP
    INTSXP,     // 02 DOUBLE  NRBAR
    REALSXP,    // 04 DOUBLE  D
    REALSXP,    // 05 DOUBLE  RBAR
    REALSXP,    // 06 DOUBLE  THETAB
    REALSXP,    // 07 DOUBLE  SSERR
    REALSXP,    // 08 DOUBLE  TOL
    LGLSXP,     // 10 LOGICAL LINDEP
    REALSXP,    // 09 DOUBLE  WORK
    INTSXP,     // 03 INTEGER IER
};
static R_NativePrimitiveArgType ssleaps_t[] = {
    INTSXP,     // 01 INTEGER NP
    REALSXP,    // 03 DOUBLE  D
    REALSXP,    // 04 DOUBLE  THETAB
    REALSXP,    // 05 DOUBLE  SSERR
    REALSXP,    // 06 DOUBLE  RSS
    INTSXP,     // 02 INTEGER IER
};
static R_NativePrimitiveArgType tolset_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NRBAR
    REALSXP,    // 04 DOUBLE  D
    REALSXP,    // 05 DOUBLE  RBAR
    REALSXP,    // 06 DOUBLE  TOL
    REALSXP,    // 07 DOUBLE  WORK
    INTSXP,     // 03 INTEGER IER
};
static R_NativePrimitiveArgType makeqr_t[] = {
    INTSXP,     // 01 INTEGER NP
    INTSXP,     // 02 INTEGER NN
    REALSXP,    // 04 DOUBLE WEIGHTS
    REALSXP,    // 05 DOUBLE TXMAT
    REALSXP,    // 06 DOUBLE YVEC
    REALSXP,    // 07 DOUBLE D
    REALSXP,    // 08 DOUBLE RBAR
    REALSXP,    // 09 DOUBLE THETAB
    REALSXP,    // 10 DOUBLE SSERR
    INTSXP,     // 03 INTEGER IER
};
static R_FortranMethodDef fortranEntries[] = {
    { "bakwrd",  (DL_FUNC)&F77_SUB(bakwrd),  20, bakwrd_t},
    { "forwrd",  (DL_FUNC)&F77_SUB(forwrd),  20, forwrd_t},
    { "seqrep",  (DL_FUNC)&F77_SUB(seqrep),  20, seqrep_t},
    { "xhaust",  (DL_FUNC)&F77_SUB(xhaust),  22, xhaust_t},
    { "initr",   (DL_FUNC)&F77_SUB(initr),   11, initr_t},
    { "sing",    (DL_FUNC)&F77_SUB(sing),    10, sing_t},
    { "ssleaps", (DL_FUNC)&F77_SUB(ssleaps),  6, ssleaps_t},
    { "tolset",  (DL_FUNC)&F77_SUB(tolset),   7, tolset_t},
    { "makeqr",  (DL_FUNC)&F77_SUB(makeqr),  10, makeqr_t},
    {NULL,       NULL,                        0, NULL}
};
void R_init_earth(DllInfo *dll) // called by R after R loads the earth package
{
    R_registerRoutines(dll, cEntries, callEntries, fortranEntries, NULL);
    R_useDynamicSymbols(dll, FALSE);
}