phylopomp
Phylodynamics for POMPs
Loading...
Searching...
No Matches
internal.h File Reference
#include <R.h>
#include <Rmath.h>
#include <Rdefines.h>
#include <assert.h>
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define R_NO_REMAP
 
#define err(...)
 
#define warn(...)
 
#define rprint(S)
 

Typedefs

typedef Rbyte raw_t
 
typedef double slate_t
 
typedef size_t name_t
 

Functions

static int random_integer (int n)
 
static void random_sample_wo_repl (int *samples, int N, int n)
 
static int set_list_elem (SEXP list, SEXP names, SEXP element, const char *name, int pos)
 
static int rcateg (double erate, double *rate, int nrate)
 

Macro Definition Documentation

◆ err

#define err ( ...)
Value:
Rf_errorcall(R_NilValue,__VA_ARGS__)

Definition at line 18 of file internal.h.

◆ R_NO_REMAP

#define R_NO_REMAP

Definition at line 4 of file internal.h.

◆ rprint

#define rprint ( S)
Value:
Rprintf("%s\n",(S).c_str())
#define S
Definition seirs_pomp.c:37

Definition at line 20 of file internal.h.

◆ warn

#define warn ( ...)
Value:
Rf_warningcall(R_NilValue,__VA_ARGS__)

Definition at line 19 of file internal.h.

Typedef Documentation

◆ name_t

typedef size_t name_t

Definition at line 54 of file internal.h.

◆ raw_t

typedef Rbyte raw_t

Definition at line 52 of file internal.h.

◆ slate_t

typedef double slate_t

Definition at line 53 of file internal.h.

Function Documentation

◆ random_integer()

static int random_integer ( int n)
inlinestatic

Definition at line 57 of file internal.h.

57 {
58 return (int) floor(R_unif_index((double) n));
59}
#define n
Definition lbdp_pomp.c:9
Here is the caller graph for this function:

◆ random_sample_wo_repl()

static void random_sample_wo_repl ( int * samples,
int N,
int n )
inlinestatic

Definition at line 62 of file internal.h.

62 {
63 int k = 0; // total input records dealt with
64 int m = 0; // number of items selected so far
65 while (m < n && k < N) {
66 int u = random_integer(N-k);
67 if (u < n-m) {
68 samples[m++] = k;
69 }
70 k++;
71 }
72}
static int random_integer(int n)
Definition internal.h:57
#define N
Definition seirs_pomp.c:36
Here is the call graph for this function:

◆ rcateg()

static int rcateg ( double erate,
double * rate,
int nrate )
inlinestatic

Definition at line 85 of file internal.h.

85 {
86 double u = erate*unif_rand();
87 int e = 0;
88 while (u > rate[e] && e < nrate) {
89 if (rate[e] < 0)
90 err("in '%s': invalid rate rate[%d]=%lg",__func__,e,rate[e]); // #nocov
91 u -= rate[e++];
92 }
93 assert(e!=nrate); // #nocov
94 return e;
95}
#define err(...)
Definition internal.h:18
static const int nrate
Definition seirs_pomp.c:7
Here is the caller graph for this function:

◆ set_list_elem()

static int set_list_elem ( SEXP list,
SEXP names,
SEXP element,
const char * name,
int pos )
inlinestatic

Definition at line 75 of file internal.h.

79 {
80 SET_ELEMENT(list,pos,element);
81 SET_STRING_ELT(names,pos,Rf_mkChar(name));
82 return ++pos;
83}
Here is the caller graph for this function: