|
a |
|
b/partyMod/src/Classes.c |
|
|
1 |
|
|
|
2 |
/** |
|
|
3 |
S4 classes for package `party' |
|
|
4 |
*\file Classes.c |
|
|
5 |
*\author $Author$ |
|
|
6 |
*\date $Date$ |
|
|
7 |
*/ |
|
|
8 |
|
|
|
9 |
#include "party.h" |
|
|
10 |
|
|
|
11 |
SEXP |
|
|
12 |
PL2_expectationSym, |
|
|
13 |
PL2_covarianceSym, |
|
|
14 |
PL2_linearstatisticSym, |
|
|
15 |
PL2_expcovinfSym, |
|
|
16 |
PL2_expcovinfssSym, |
|
|
17 |
PL2_sumweightsSym, |
|
|
18 |
PL2_dimensionSym, |
|
|
19 |
PL2_MPinvSym, |
|
|
20 |
PL2_rankSym, |
|
|
21 |
PL2_svdmemSym, |
|
|
22 |
PL2_methodSym, |
|
|
23 |
PL2_jobuSym, |
|
|
24 |
PL2_jobvSym, |
|
|
25 |
PL2_uSym, |
|
|
26 |
PL2_vSym, |
|
|
27 |
PL2_sSym, |
|
|
28 |
PL2_pSym, |
|
|
29 |
PL2_teststatSym, |
|
|
30 |
PL2_pvalueSym, |
|
|
31 |
PL2_tolSym, |
|
|
32 |
PL2_maxptsSym, |
|
|
33 |
PL2_absepsSym, |
|
|
34 |
PL2_relepsSym, |
|
|
35 |
PL2_minprobSym, |
|
|
36 |
PL2_minsplitSym, |
|
|
37 |
PL2_minbucketSym, |
|
|
38 |
PL2_variablesSym, |
|
|
39 |
PL2_transformationsSym, |
|
|
40 |
PL2_is_nominalSym, |
|
|
41 |
PL2_is_ordinalSym, |
|
|
42 |
PL2_is_censoredSym, |
|
|
43 |
PL2_orderingSym, |
|
|
44 |
PL2_levelsSym, |
|
|
45 |
PL2_scoresSym, |
|
|
46 |
PL2_has_missingsSym, |
|
|
47 |
PL2_whichNASym, |
|
|
48 |
PL2_test_trafoSym, |
|
|
49 |
PL2_predict_trafoSym, |
|
|
50 |
PL2_nobsSym, |
|
|
51 |
PL2_ninputsSym, |
|
|
52 |
PL2_linexpcov2sampleSym, |
|
|
53 |
PL2_weightsSym, |
|
|
54 |
PL2_varmemorySym, |
|
|
55 |
PL2_splitstatisticsSym, |
|
|
56 |
PL2_savesplitstatsSym, |
|
|
57 |
PL2_responsesSym, |
|
|
58 |
PL2_inputsSym, |
|
|
59 |
PL2_testtypeSym, |
|
|
60 |
PL2_nresampleSym, |
|
|
61 |
PL2_varctrlSym, |
|
|
62 |
PL2_splitctrlSym, |
|
|
63 |
PL2_gtctrlSym, |
|
|
64 |
PL2_mincriterionSym, |
|
|
65 |
PL2_maxsurrogateSym, |
|
|
66 |
PL2_randomsplitsSym, |
|
|
67 |
PL2_mtrySym, |
|
|
68 |
PL2_dontuseSym, |
|
|
69 |
PL2_dontusetmpSym, |
|
|
70 |
PL2_stumpSym, |
|
|
71 |
PL2_maxdepthSym, |
|
|
72 |
PL2_tgctrlSym, |
|
|
73 |
PL2_ntreeSym, |
|
|
74 |
PL2_replaceSym, |
|
|
75 |
PL2_fractionSym, |
|
|
76 |
PL2_traceSym, |
|
|
77 |
PL2_dropcriterionSym, |
|
|
78 |
PL2_compressSym, |
|
|
79 |
PL2_expandSym, |
|
|
80 |
PL2_varOnceSym; |
|
|
81 |
|
|
|
82 |
SEXP party_init(void) { |
|
|
83 |
PL2_expectationSym = install("expectation"); |
|
|
84 |
PL2_covarianceSym = install("covariance"); |
|
|
85 |
PL2_linearstatisticSym = install("linearstatistic"); |
|
|
86 |
PL2_expcovinfSym = install("expcovinf"); |
|
|
87 |
PL2_expcovinfssSym = install("expcovinfss"); |
|
|
88 |
PL2_sumweightsSym = install("sumweights"); |
|
|
89 |
PL2_dimensionSym = install("dimension"); |
|
|
90 |
PL2_MPinvSym = install("MPinv"); |
|
|
91 |
PL2_rankSym = install("rank"); |
|
|
92 |
PL2_svdmemSym = install("svdmem"); |
|
|
93 |
PL2_methodSym = install("method"); |
|
|
94 |
PL2_jobuSym = install("jobu"); |
|
|
95 |
PL2_jobvSym = install("jobv"); |
|
|
96 |
PL2_uSym = install("u"); |
|
|
97 |
PL2_vSym = install("v"); |
|
|
98 |
PL2_sSym = install("s"); |
|
|
99 |
PL2_pSym = install("p"); |
|
|
100 |
PL2_teststatSym = install("teststat"); |
|
|
101 |
PL2_pvalueSym = install("pvalue"); |
|
|
102 |
PL2_tolSym = install("tol"); |
|
|
103 |
PL2_maxptsSym = install("maxpts"); |
|
|
104 |
PL2_absepsSym = install("abseps"); |
|
|
105 |
PL2_relepsSym = install("releps"); |
|
|
106 |
PL2_minsplitSym = install("minsplit"); |
|
|
107 |
PL2_minprobSym = install("minprob"); |
|
|
108 |
PL2_minbucketSym = install("minbucket"); |
|
|
109 |
PL2_variablesSym = install("variables"); |
|
|
110 |
PL2_transformationsSym = install("transformations"); |
|
|
111 |
PL2_is_nominalSym = install("is_nominal"); |
|
|
112 |
PL2_is_ordinalSym = install("is_ordinal"); |
|
|
113 |
PL2_is_censoredSym = install("is_censored"); |
|
|
114 |
PL2_orderingSym = install("ordering"); |
|
|
115 |
PL2_levelsSym = install("levels"); |
|
|
116 |
PL2_scoresSym = install("scores"); |
|
|
117 |
PL2_has_missingsSym = install("has_missings"); |
|
|
118 |
PL2_whichNASym = install("whichNA"); |
|
|
119 |
PL2_test_trafoSym = install("test_trafo"); |
|
|
120 |
PL2_predict_trafoSym = install("predict_trafo"); |
|
|
121 |
PL2_nobsSym = install("nobs"); |
|
|
122 |
PL2_ninputsSym = install("ninputs"); |
|
|
123 |
PL2_linexpcov2sampleSym = install("linexpcov2sample"); |
|
|
124 |
PL2_weightsSym = install("weights"); |
|
|
125 |
PL2_varmemorySym = install("varmemory"); |
|
|
126 |
PL2_splitstatisticsSym = install("splitstatistics"); |
|
|
127 |
PL2_savesplitstatsSym = install("savesplitstats"); |
|
|
128 |
PL2_responsesSym = install("responses"); |
|
|
129 |
PL2_inputsSym = install("inputs"); |
|
|
130 |
PL2_testtypeSym = install("testtype"); |
|
|
131 |
PL2_nresampleSym = install("nresample"); |
|
|
132 |
PL2_varctrlSym = install("varctrl"); |
|
|
133 |
PL2_splitctrlSym = install("splitctrl"); |
|
|
134 |
PL2_gtctrlSym = install("gtctrl"); |
|
|
135 |
PL2_mincriterionSym = install("mincriterion"); |
|
|
136 |
PL2_maxsurrogateSym = install("maxsurrogate"); |
|
|
137 |
PL2_randomsplitsSym = install("randomsplits"); |
|
|
138 |
PL2_mtrySym = install("mtry"); |
|
|
139 |
PL2_dontuseSym = install("dontuse"); |
|
|
140 |
PL2_dontusetmpSym = install("dontusetmp"); |
|
|
141 |
PL2_stumpSym = install("stump"); |
|
|
142 |
PL2_maxdepthSym = install("maxdepth"); |
|
|
143 |
PL2_tgctrlSym = install("tgctrl"); |
|
|
144 |
PL2_ntreeSym = install("ntree"), |
|
|
145 |
PL2_replaceSym = install("replace"), |
|
|
146 |
PL2_fractionSym = install("fraction"); |
|
|
147 |
PL2_traceSym = install("trace"); |
|
|
148 |
PL2_dropcriterionSym = install("dropcriterion"); |
|
|
149 |
PL2_compressSym = install("compress"); |
|
|
150 |
PL2_expandSym = install("expand"); |
|
|
151 |
PL2_varOnceSym = install("varOnce"); |
|
|
152 |
return(R_NilValue); |
|
|
153 |
} |
|
|
154 |
|
|
|
155 |
/* accessor functions */ |
|
|
156 |
|
|
|
157 |
int get_dimension(SEXP object) { |
|
|
158 |
return(INTEGER(GET_SLOT(object, PL2_dimensionSym))[0]); |
|
|
159 |
} |
|
|
160 |
|
|
|
161 |
int get_teststat(SEXP object) { |
|
|
162 |
return(INTEGER(GET_SLOT(object, PL2_teststatSym))[0]); |
|
|
163 |
} |
|
|
164 |
|
|
|
165 |
int get_pvalue(SEXP object) { |
|
|
166 |
return(INTEGER(GET_SLOT(object, PL2_pvalueSym))[0]); |
|
|
167 |
} |
|
|
168 |
|
|
|
169 |
double get_tol(SEXP object) { |
|
|
170 |
return(REAL(GET_SLOT(object, PL2_tolSym))[0]); |
|
|
171 |
} |
|
|
172 |
|
|
|
173 |
int get_maxpts(SEXP object) { |
|
|
174 |
return(INTEGER(GET_SLOT(object, PL2_maxptsSym))[0]); |
|
|
175 |
} |
|
|
176 |
|
|
|
177 |
double get_abseps(SEXP object) { |
|
|
178 |
return(REAL(GET_SLOT(object, PL2_absepsSym))[0]); |
|
|
179 |
} |
|
|
180 |
|
|
|
181 |
double get_releps(SEXP object) { |
|
|
182 |
return(REAL(GET_SLOT(object, PL2_relepsSym))[0]); |
|
|
183 |
} |
|
|
184 |
|
|
|
185 |
double get_minsplit(SEXP object) { |
|
|
186 |
return(REAL(GET_SLOT(object, PL2_minsplitSym))[0]); |
|
|
187 |
} |
|
|
188 |
|
|
|
189 |
double get_minprob(SEXP object) { |
|
|
190 |
return(REAL(GET_SLOT(object, PL2_minprobSym))[0]); |
|
|
191 |
} |
|
|
192 |
|
|
|
193 |
double get_minbucket(SEXP object) { |
|
|
194 |
return(REAL(GET_SLOT(object, PL2_minbucketSym))[0]); |
|
|
195 |
} |
|
|
196 |
|
|
|
197 |
SEXP get_transformation(SEXP object, int variable) { |
|
|
198 |
return(VECTOR_ELT( |
|
|
199 |
GET_SLOT(object, PL2_transformationsSym), |
|
|
200 |
variable - 1)); |
|
|
201 |
} |
|
|
202 |
|
|
|
203 |
SEXP get_test_trafo(SEXP object) { |
|
|
204 |
return(GET_SLOT(object, PL2_test_trafoSym)); |
|
|
205 |
} |
|
|
206 |
|
|
|
207 |
SEXP get_predict_trafo(SEXP object) { |
|
|
208 |
return(GET_SLOT(object, PL2_predict_trafoSym)); |
|
|
209 |
} |
|
|
210 |
|
|
|
211 |
|
|
|
212 |
SEXP get_variable(SEXP object, int variable) { |
|
|
213 |
return(VECTOR_ELT( |
|
|
214 |
GET_SLOT(object, PL2_variablesSym), |
|
|
215 |
variable - 1)); |
|
|
216 |
} |
|
|
217 |
|
|
|
218 |
int is_nominal(SEXP object, int variable) { |
|
|
219 |
return(INTEGER(GET_SLOT(object, PL2_is_nominalSym))[variable - 1]); |
|
|
220 |
} |
|
|
221 |
|
|
|
222 |
int is_ordinal(SEXP object, int variable) { |
|
|
223 |
return(INTEGER(GET_SLOT(object, PL2_is_ordinalSym))[variable - 1]); |
|
|
224 |
} |
|
|
225 |
|
|
|
226 |
int is_censored(SEXP object, int variable) { |
|
|
227 |
return(INTEGER(GET_SLOT(object, PL2_is_censoredSym))[variable - 1]); |
|
|
228 |
} |
|
|
229 |
|
|
|
230 |
int has_missings(SEXP object, int variable) { |
|
|
231 |
return(INTEGER(GET_SLOT(object, PL2_has_missingsSym))[variable - 1]); |
|
|
232 |
} |
|
|
233 |
|
|
|
234 |
SEXP get_ordering(SEXP object, int variable) { |
|
|
235 |
if (!is_nominal(object, variable)) { |
|
|
236 |
return(VECTOR_ELT( |
|
|
237 |
GET_SLOT(object, PL2_orderingSym), |
|
|
238 |
variable - 1)); |
|
|
239 |
} else { |
|
|
240 |
error("Variable %d is not ordered", variable); |
|
|
241 |
return(R_NilValue); |
|
|
242 |
} |
|
|
243 |
} |
|
|
244 |
|
|
|
245 |
SEXP get_levels(SEXP object, int variable) { |
|
|
246 |
if (is_nominal(object, variable) || |
|
|
247 |
is_ordinal(object, variable)) { |
|
|
248 |
return(VECTOR_ELT( |
|
|
249 |
GET_SLOT(object, PL2_levelsSym), |
|
|
250 |
variable - 1)); |
|
|
251 |
} else { |
|
|
252 |
error("Variable %d is not an (ordered) factor", variable); |
|
|
253 |
return(R_NilValue); |
|
|
254 |
} |
|
|
255 |
} |
|
|
256 |
|
|
|
257 |
SEXP get_scores(SEXP object, int variable) { |
|
|
258 |
if (is_ordinal(object, variable)) { |
|
|
259 |
return(VECTOR_ELT( |
|
|
260 |
GET_SLOT(object, PL2_scoresSym), |
|
|
261 |
variable - 1)); |
|
|
262 |
} else { |
|
|
263 |
error("Variable %d is not an ordered factor", variable); |
|
|
264 |
return(R_NilValue); |
|
|
265 |
} |
|
|
266 |
} |
|
|
267 |
|
|
|
268 |
SEXP get_missings(SEXP object, int variable) { |
|
|
269 |
if (has_missings(object, variable)) { |
|
|
270 |
return(VECTOR_ELT( |
|
|
271 |
GET_SLOT(object, PL2_whichNASym), |
|
|
272 |
variable - 1)); |
|
|
273 |
} else { |
|
|
274 |
error("Variable %d has no missing values", variable); |
|
|
275 |
return(R_NilValue); |
|
|
276 |
} |
|
|
277 |
} |
|
|
278 |
|
|
|
279 |
SEXP get_varmemory(SEXP object, int variable) { |
|
|
280 |
return(VECTOR_ELT(GET_SLOT(object, PL2_varmemorySym), |
|
|
281 |
variable - 1)); |
|
|
282 |
} |
|
|
283 |
|
|
|
284 |
int get_savesplitstats(SEXP object) { |
|
|
285 |
return(INTEGER(GET_SLOT(object, PL2_savesplitstatsSym))[0]); |
|
|
286 |
} |
|
|
287 |
|
|
|
288 |
SEXP get_splitstatistics(SEXP object) { |
|
|
289 |
return(GET_SLOT(object, PL2_splitstatisticsSym)); |
|
|
290 |
} |
|
|
291 |
|
|
|
292 |
int get_nobs(SEXP object) { |
|
|
293 |
return(INTEGER(GET_SLOT(object, PL2_nobsSym))[0]); |
|
|
294 |
} |
|
|
295 |
|
|
|
296 |
int get_ninputs(SEXP object) { |
|
|
297 |
return(INTEGER(GET_SLOT(object, PL2_ninputsSym))[0]); |
|
|
298 |
} |
|
|
299 |
|
|
|
300 |
SEXP get_weights(SEXP object) { |
|
|
301 |
return(GET_SLOT(object, PL2_weightsSym)); |
|
|
302 |
} |
|
|
303 |
|
|
|
304 |
int get_testtype(SEXP object) { |
|
|
305 |
return(INTEGER(GET_SLOT(object, PL2_testtypeSym))[0]); |
|
|
306 |
} |
|
|
307 |
|
|
|
308 |
int get_nresample(SEXP object) { |
|
|
309 |
return(INTEGER(GET_SLOT(object, PL2_nresampleSym))[0]); |
|
|
310 |
} |
|
|
311 |
|
|
|
312 |
SEXP get_varctrl(SEXP object) { |
|
|
313 |
return(GET_SLOT(object, PL2_varctrlSym)); |
|
|
314 |
} |
|
|
315 |
|
|
|
316 |
SEXP get_splitctrl(SEXP object) { |
|
|
317 |
return(GET_SLOT(object, PL2_splitctrlSym)); |
|
|
318 |
} |
|
|
319 |
|
|
|
320 |
SEXP get_gtctrl(SEXP object) { |
|
|
321 |
return(GET_SLOT(object, PL2_gtctrlSym)); |
|
|
322 |
} |
|
|
323 |
|
|
|
324 |
SEXP get_tgctrl(SEXP object) { |
|
|
325 |
return(GET_SLOT(object, PL2_tgctrlSym)); |
|
|
326 |
} |
|
|
327 |
|
|
|
328 |
double get_mincriterion(SEXP object) { |
|
|
329 |
return(REAL(GET_SLOT(object, PL2_mincriterionSym))[0]); |
|
|
330 |
} |
|
|
331 |
|
|
|
332 |
int get_maxsurrogate(SEXP object) { |
|
|
333 |
return(INTEGER(GET_SLOT(object, PL2_maxsurrogateSym))[0]); |
|
|
334 |
} |
|
|
335 |
|
|
|
336 |
int get_randomsplits(SEXP object) { |
|
|
337 |
return(INTEGER(GET_SLOT(object, PL2_randomsplitsSym))[0]); |
|
|
338 |
} |
|
|
339 |
|
|
|
340 |
SEXP get_mtry(SEXP object) { |
|
|
341 |
return(GET_SLOT(object, PL2_mtrySym)); |
|
|
342 |
} |
|
|
343 |
|
|
|
344 |
SEXP get_dontuse(SEXP object) { |
|
|
345 |
return(GET_SLOT(object, PL2_dontuseSym)); |
|
|
346 |
} |
|
|
347 |
|
|
|
348 |
SEXP get_dontusetmp(SEXP object) { |
|
|
349 |
return(GET_SLOT(object, PL2_dontusetmpSym)); |
|
|
350 |
} |
|
|
351 |
|
|
|
352 |
int get_stump(SEXP object) { |
|
|
353 |
return(INTEGER(GET_SLOT(object, PL2_stumpSym))[0]); |
|
|
354 |
} |
|
|
355 |
|
|
|
356 |
int get_only_use_variable_once(SEXP object) { |
|
|
357 |
return(INTEGER(GET_SLOT(object, PL2_varOnceSym))[0]); |
|
|
358 |
} |
|
|
359 |
|
|
|
360 |
int check_depth(SEXP object, int depth) { |
|
|
361 |
int maxdepth; |
|
|
362 |
maxdepth = INTEGER(GET_SLOT(object, PL2_maxdepthSym))[0]; |
|
|
363 |
if (maxdepth == 0) return(1); |
|
|
364 |
if (maxdepth < 1) error("maxdepth is less than one"); |
|
|
365 |
return(depth <= maxdepth); |
|
|
366 |
} |
|
|
367 |
|
|
|
368 |
int get_ntree(SEXP object) { |
|
|
369 |
return(INTEGER(GET_SLOT(object, PL2_ntreeSym))[0]); |
|
|
370 |
} |
|
|
371 |
|
|
|
372 |
int get_replace(SEXP object) { |
|
|
373 |
return(INTEGER(GET_SLOT(object, PL2_replaceSym))[0]); |
|
|
374 |
} |
|
|
375 |
|
|
|
376 |
double get_fraction(SEXP object) { |
|
|
377 |
return(REAL(GET_SLOT(object, PL2_fractionSym))[0]); |
|
|
378 |
} |
|
|
379 |
|
|
|
380 |
int get_trace(SEXP object) { |
|
|
381 |
return(INTEGER(GET_SLOT(object, PL2_traceSym))[0]); |
|
|
382 |
} |
|
|
383 |
|
|
|
384 |
int get_dropcriterion(SEXP object) { |
|
|
385 |
return(INTEGER(GET_SLOT(object, PL2_dropcriterionSym))[0]); |
|
|
386 |
} |
|
|
387 |
|
|
|
388 |
SEXP get_compress(SEXP object) { |
|
|
389 |
return(GET_SLOT(object, PL2_compressSym)); |
|
|
390 |
} |
|
|
391 |
|
|
|
392 |
SEXP get_expand(SEXP object) { |
|
|
393 |
return(GET_SLOT(object, PL2_expandSym)); |
|
|
394 |
} |