1 #ifndef _PHYLOPOMP_INTERNAL_H_
2 #define _PHYLOPOMP_INTERNAL_H_
18 #define err(...) Rf_errorcall(R_NilValue,__VA_ARGS__)
19 #define warn(...) Rf_warningcall(R_NilValue,__VA_ARGS__)
20 #define rprint(S) Rprintf("%s\n",(S).c_str())
26 #define err(...) {printf(__VA_ARGS__); printf("\n"); exit(-1);}
27 #define warn(...) {printf(__VA_ARGS__); printf("\n");}
28 #define rprint(S) printf("%s\n",(S).c_str())
34 #define mkChar Rf_mkChar
35 #define mkString Rf_mkString
36 #define ScalarInteger Rf_ScalarInteger
37 #define ScalarReal Rf_ScalarReal
38 #define install Rf_install
39 #define isNull Rf_isNull
49 return (
int) floor(R_unif_index((
double)
n));
56 while (m <
n && k <
N) {
68 SEXP list, SEXP names, SEXP element,
69 const char *name,
int pos
71 SET_ELEMENT(list,pos,element);
72 SET_STRING_ELT(names,pos,Rf_mkChar(name));
76 static inline int rcateg (
double erate,
double *rate,
int nrate) {
77 double u = erate*unif_rand();
79 while (u > rate[e] && e <
nrate) {
81 err(
"in '%s': invalid rate rate[%d]=%lg",__func__,e,rate[e]);
static int rcateg(double erate, double *rate, int nrate)
static int set_list_elem(SEXP list, SEXP names, SEXP element, const char *name, int pos)
static int random_integer(int n)
static void random_sample_wo_repl(int *samples, int N, int n)