phylopomp
Phylodynamics for POMPs
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:33

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 45 of file internal.h.

◆ raw_t

typedef Rbyte raw_t

Definition at line 43 of file internal.h.

◆ slate_t

typedef double slate_t

Definition at line 44 of file internal.h.

Function Documentation

◆ random_integer()

static int random_integer ( int n)
inlinestatic

Definition at line 48 of file internal.h.

48 {
49 return (int) floor(R_unif_index((double) n));
50}
#define n
Definition lbdp_pomp.c:8
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 53 of file internal.h.

53 {
54 int k = 0; // total input records dealt with
55 int m = 0; // number of items selected so far
56 while (m < n && k < N) {
57 int u = random_integer(N-k);
58 if (u < n-m) {
59 samples[m++] = k;
60 }
61 k++;
62 }
63}
static int random_integer(int n)
Definition internal.h:48
#define N
Definition seirs_pomp.c:32
Here is the call graph for this function:

◆ rcateg()

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

Definition at line 76 of file internal.h.

76 {
77 double u = erate*unif_rand();
78 int e = 0;
79 while (u > rate[e] && e < nrate) {
80 if (rate[e] < 0)
81 err("in '%s': invalid rate rate[%d]=%lg",__func__,e,rate[e]); // #nocov
82 u -= rate[e++];
83 }
84 assert(e!=nrate); // #nocov
85 return e;
86}
#define err(...)
Definition internal.h:18
static const int nrate
Definition seirs_pomp.c:4
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 66 of file internal.h.

70 {
71 SET_ELEMENT(list,pos,element);
72 SET_STRING_ELT(names,pos,Rf_mkChar(name));
73 return ++pos;
74}
Here is the caller graph for this function: