phylopomp
Phylodynamics for POMPs
Loading...
Searching...
No Matches
generics.h File Reference
#include "internal.h"
Include dependency graph for generics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAKEFN(X, TYPE)
 
#define REVIVEFN(X, TYPE)
 
#define RUNFN(X, TYPE)
 
#define YAMLFN(X, TYPE)
 
#define GENERICS(X, TYPE)
 

Functions

template<class TYPE>
SEXP ndeme (TYPE &X)
 
template<class TYPE>
SEXP nsample (TYPE &X)
 
template<class TYPE>
SEXP nroot (TYPE &X)
 
template<class TYPE>
SEXP timezero (TYPE &X)
 
template<class TYPE>
SEXP time (TYPE &X)
 
template<class TYPE>
SEXP serial (const TYPE &X)
 binary serialization
 
template<class TYPE>
SEXP yaml (const TYPE &X)
 human/machine readable output
 
template<class TYPE>
SEXP structure (const TYPE &X)
 structure in R list format
 
template<class TYPE>
SEXP newick (const TYPE &X, bool extended)
 tree in newick format
 
template<class TYPE>
SEXP lineage_count (const TYPE &G)
 number of lineages through time
 
template<class TYPE>
SEXP gendat (const TYPE &G)
 data-frame format
 
template<class TYPE>
SEXP make (SEXP Params, SEXP IVPs, SEXP T0)
 initialization
 
template<class TYPE>
SEXP revive (SEXP State, SEXP Params)
 refresh parameters
 
template<class TYPE>
SEXP run (SEXP State, SEXP Tout)
 run simulations
 

Macro Definition Documentation

◆ GENERICS

#define GENERICS ( X,
TYPE )
Value:
extern "C" { \
\
MAKEFN(X,TYPE) \
\
REVIVEFN(X,TYPE) \
\
RUNFN(X,TYPE) \
\
YAMLFN(X,TYPE) \
\
} \

Definition at line 133 of file generics.h.

133#define GENERICS(X,TYPE) \
134 extern "C" { \
135 \
136 MAKEFN(X,TYPE) \
137 \
138 REVIVEFN(X,TYPE) \
139 \
140 RUNFN(X,TYPE) \
141 \
142 YAMLFN(X,TYPE) \
143 \
144 } \
145

◆ MAKEFN

#define MAKEFN ( X,
TYPE )
Value:
SEXP make ## X (SEXP Params, SEXP IVPs, SEXP T0) { \
return make<TYPE>(Params,IVPs,T0); \
} \
SEXP make(SEXP Params, SEXP IVPs, SEXP T0)
initialization
Definition generics.h:73

Definition at line 117 of file generics.h.

117#define MAKEFN(X,TYPE) SEXP make ## X (SEXP Params, SEXP IVPs, SEXP T0) { \
118 return make<TYPE>(Params,IVPs,T0); \
119 } \
120

◆ REVIVEFN

#define REVIVEFN ( X,
TYPE )
Value:
SEXP revive ## X (SEXP State, SEXP Params) { \
return revive<TYPE>(State,Params); \
} \
SEXP revive(SEXP State, SEXP Params)
refresh parameters
Definition generics.h:92

Definition at line 121 of file generics.h.

121#define REVIVEFN(X,TYPE) SEXP revive ## X (SEXP State, SEXP Params) { \
122 return revive<TYPE>(State,Params); \
123 } \
124

◆ RUNFN

#define RUNFN ( X,
TYPE )
Value:
SEXP run ## X (SEXP State, SEXP Times) { \
return run<TYPE>(State,Times); \
} \
SEXP run(SEXP State, SEXP Tout)
run simulations
Definition generics.h:104

Definition at line 125 of file generics.h.

125#define RUNFN(X,TYPE) SEXP run ## X (SEXP State, SEXP Times) { \
126 return run<TYPE>(State,Times); \
127 } \
128

◆ YAMLFN

#define YAMLFN ( X,
TYPE )
Value:
SEXP yaml ## X (SEXP State) { \
return yaml<TYPE>(State); \
} \
SEXP yaml(const TYPE &X)
human/machine readable output
Definition generics.h:43

Definition at line 129 of file generics.h.

129#define YAMLFN(X,TYPE) SEXP yaml ## X (SEXP State) { \
130 return yaml<TYPE>(State); \
131 } \
132

Function Documentation

◆ gendat()

template<class TYPE>
SEXP gendat ( const TYPE & G)

data-frame format

Definition at line 67 of file generics.h.

67 {
68 return G.gendat();
69}

◆ lineage_count()

template<class TYPE>
SEXP lineage_count ( const TYPE & G)

number of lineages through time

Definition at line 61 of file generics.h.

61 {
62 return G.lineage_count();
63}
Here is the caller graph for this function:

◆ make()

template<class TYPE>
SEXP make ( SEXP Params,
SEXP IVPs,
SEXP T0 )

initialization

Definition at line 73 of file generics.h.

73 {
74 SEXP o;
75 PROTECT(Params = AS_NUMERIC(Params));
76 PROTECT(IVPs = AS_NUMERIC(IVPs));
77 PROTECT(T0 = AS_NUMERIC(T0));
78 GetRNGstate();
79 TYPE X = *REAL(T0);
80 X.update_params(REAL(Params),LENGTH(Params));
81 X.update_IVPs(REAL(IVPs),LENGTH(IVPs));
82 X.rinit();
83 X.update_clocks();
84 PutRNGstate();
85 PROTECT(o = serial(X));
86 UNPROTECT(4);
87 return o;
88}
SEXP serial(const TYPE &X)
binary serialization
Definition generics.h:33
Here is the call graph for this function:

◆ ndeme()

template<class TYPE>
SEXP ndeme ( TYPE & X)

Definition at line 7 of file generics.h.

7 {
8 return ScalarInteger(X.ndeme());
9}
Here is the caller graph for this function:

◆ newick()

template<class TYPE>
SEXP newick ( const TYPE & X,
bool extended )

tree in newick format

Definition at line 55 of file generics.h.

55 {
56 return mkString(X.newick(extended).c_str());
57}
Here is the caller graph for this function:

◆ nroot()

template<class TYPE>
SEXP nroot ( TYPE & X)

Definition at line 17 of file generics.h.

17 {
18 return ScalarInteger(X.nroot());
19}
Here is the caller graph for this function:

◆ nsample()

template<class TYPE>
SEXP nsample ( TYPE & X)

Definition at line 12 of file generics.h.

12 {
13 return ScalarInteger(X.nsample());
14}
Here is the caller graph for this function:

◆ revive()

template<class TYPE>
SEXP revive ( SEXP State,
SEXP Params )

refresh parameters

Definition at line 92 of file generics.h.

92 {
93 SEXP o;
94 TYPE X = State;
95 PROTECT(Params = AS_NUMERIC(Params));
96 X.update_params(REAL(Params),LENGTH(Params));
97 PROTECT(o = serial(X));
98 UNPROTECT(2);
99 return o;
100}
Here is the call graph for this function:

◆ run()

template<class TYPE>
SEXP run ( SEXP State,
SEXP Tout )

run simulations

Definition at line 104 of file generics.h.

104 {
105 SEXP out;
106 TYPE X = State;
107 PROTECT(Tout = AS_NUMERIC(Tout));
108 GetRNGstate();
109 X.valid();
110 X.play(*REAL(Tout));
111 PutRNGstate();
112 PROTECT(out = serial(X));
113 UNPROTECT(2);
114 return out;
115}
Here is the call graph for this function:

◆ serial()

template<class TYPE>
SEXP serial ( const TYPE & X)

binary serialization

Definition at line 33 of file generics.h.

33 {
34 SEXP out;
35 PROTECT(out = NEW_RAW(X.bytesize()));
36 X >> RAW(out);
37 UNPROTECT(1);
38 return out;
39}
Here is the caller graph for this function:

◆ structure()

template<class TYPE>
SEXP structure ( const TYPE & X)

structure in R list format

Definition at line 49 of file generics.h.

49 {
50 return X.structure();
51}
Here is the caller graph for this function:

◆ time()

template<class TYPE>
SEXP time ( TYPE & X)

Definition at line 27 of file generics.h.

27 {
28 return ScalarReal(X.time());
29}
Here is the caller graph for this function:

◆ timezero()

template<class TYPE>
SEXP timezero ( TYPE & X)

Definition at line 22 of file generics.h.

22 {
23 return ScalarReal(X.timezero());
24}
Here is the caller graph for this function:

◆ yaml()

template<class TYPE>
SEXP yaml ( const TYPE & X)

human/machine readable output

Definition at line 43 of file generics.h.

43 {
44 return mkString(X.yaml().c_str());
45}
Here is the caller graph for this function: