Go to the source code of this file.
|
| template<class TYPE> |
| SEXP | ndeme (TYPE &X) |
| |
| template<class TYPE> |
| SEXP | nsample (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 | describe (const TYPE &X) |
| | human readable output
|
| |
| template<class TYPE> |
| SEXP | structure (const TYPE &X) |
| | structure in R list format
|
| |
| template<class TYPE> |
| SEXP | newick (const TYPE &X) |
| | 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
|
| |
| template<class TYPE> |
| SEXP | genealogy (SEXP State) |
| | extract the bare genealogy
|
| |
◆ GENEALFN
| #define GENEALFN |
( |
| X, |
|
|
| TYPE ) |
Value: SEXP geneal ## X (SEXP State) { \
} \
SEXP genealogy(SEXP State)
extract the bare genealogy
Definition at line 141 of file generics.h.
141#define GENEALFN(X,TYPE) SEXP geneal ## X (SEXP State) { \
142 return genealogy<TYPE>(State); \
143 } \
144
◆ GENERICS
| #define GENERICS |
( |
| X, |
|
|
| TYPE ) |
Value: extern "C" { \
\
MAKEFN(X,TYPE) \
\
REVIVEFN(X,TYPE) \
\
RUNFN(X,TYPE) \
\
GENEALFN(X,TYPE) \
\
YAMLFN(X,TYPE) \
\
} \
Definition at line 149 of file generics.h.
149#define GENERICS(X,TYPE) \
150 extern "C" { \
151 \
152 MAKEFN(X,TYPE) \
153 \
154 REVIVEFN(X,TYPE) \
155 \
156 RUNFN(X,TYPE) \
157 \
158 GENEALFN(X,TYPE) \
159 \
160 YAMLFN(X,TYPE) \
161 \
162 } \
163
◆ MAKEFN
| #define MAKEFN |
( |
| X, |
|
|
| TYPE ) |
Value: SEXP
make ## X (SEXP Params, SEXP IVPs, SEXP T0) { \
} \
SEXP make(SEXP Params, SEXP IVPs, SEXP T0)
initialization
Definition at line 129 of file generics.h.
129#define MAKEFN(X,TYPE) SEXP make ## X (SEXP Params, SEXP IVPs, SEXP T0) { \
130 return make<TYPE>(Params,IVPs,T0); \
131 } \
132
◆ REVIVEFN
| #define REVIVEFN |
( |
| X, |
|
|
| TYPE ) |
Value: SEXP
revive ## X (SEXP State, SEXP Params) { \
} \
SEXP revive(SEXP State, SEXP Params)
refresh parameters
Definition at line 133 of file generics.h.
133#define REVIVEFN(X,TYPE) SEXP revive ## X (SEXP State, SEXP Params) { \
134 return revive<TYPE>(State,Params); \
135 } \
136
◆ RUNFN
| #define RUNFN |
( |
| X, |
|
|
| TYPE ) |
Value: SEXP
run ## X (SEXP State, SEXP Times) { \
} \
SEXP run(SEXP State, SEXP Tout)
run simulations
Definition at line 137 of file generics.h.
137#define RUNFN(X,TYPE) SEXP run ## X (SEXP State, SEXP Times) { \
138 return run<TYPE>(State,Times); \
139 } \
140
◆ YAMLFN
| #define YAMLFN |
( |
| X, |
|
|
| TYPE ) |
Value: SEXP
yaml ## X (SEXP State) { \
} \
SEXP yaml(SEXP State)
extract a YAML description
Definition at line 145 of file generics.h.
145#define YAMLFN(X,TYPE) SEXP yaml ## X (SEXP State) { \
146 return yaml<TYPE>(State); \
147 } \
148
◆ describe()
template<class TYPE>
| SEXP describe |
( |
const TYPE & | X | ) |
|
human readable output
Definition at line 44 of file generics.h.
44 {
45 return mkString(X.describe().c_str());
46}
◆ gendat()
template<class TYPE>
| SEXP gendat |
( |
const TYPE & | G | ) |
|
data-frame format
Definition at line 68 of file generics.h.
68 {
69 return G.gendat();
70}
◆ genealogy()
template<class TYPE>
| SEXP genealogy |
( |
SEXP | State | ) |
|
extract the bare genealogy
Definition at line 120 of file generics.h.
120 {
121 TYPE A = State;
122 SEXP out;
123 PROTECT(out =
serial(A.geneal));
124 SET_ATTR(out,install("class"),mkString("gpgen"));
125 UNPROTECT(1);
126 return out;
127}
SEXP serial(const TYPE &X)
binary serialization
◆ lineage_count()
template<class TYPE>
| SEXP lineage_count |
( |
const TYPE & | G | ) |
|
number of lineages through time
Definition at line 62 of file generics.h.
62 {
63 return G.lineage_count();
64}
◆ make()
template<class TYPE>
| SEXP make |
( |
SEXP | Params, |
|
|
SEXP | IVPs, |
|
|
SEXP | T0 ) |
initialization
Definition at line 74 of file generics.h.
74 {
75 SEXP o;
76 PROTECT(Params = AS_NUMERIC(Params));
77 PROTECT(IVPs = AS_NUMERIC(IVPs));
78 PROTECT(T0 = AS_NUMERIC(T0));
79 GetRNGstate();
80 TYPE X = *REAL(T0);
81 X.update_params(REAL(Params),LENGTH(Params));
82 X.update_IVPs(REAL(IVPs),LENGTH(IVPs));
83 X.rinit();
84 X.update_clocks();
85 PutRNGstate();
87 UNPROTECT(4);
88 return o;
89}
◆ ndeme()
Definition at line 7 of file generics.h.
7 {
8 return ScalarInteger(X.ndeme());
9}
◆ newick()
template<class TYPE>
| SEXP newick |
( |
const TYPE & | X | ) |
|
tree in newick format
Definition at line 56 of file generics.h.
56 {
57 return mkString(X.newick().c_str());
58}
◆ nsample()
Definition at line 12 of file generics.h.
12 {
13 return ScalarInteger(X.nsample());
14}
◆ revive()
template<class TYPE>
| SEXP revive |
( |
SEXP | State, |
|
|
SEXP | Params ) |
refresh parameters
Definition at line 93 of file generics.h.
93 {
94 SEXP o;
95 TYPE X = State;
96 PROTECT(Params = AS_NUMERIC(Params));
97 X.update_params(REAL(Params),LENGTH(Params));
99 UNPROTECT(2);
100 return o;
101}
◆ run()
template<class TYPE>
| SEXP run |
( |
SEXP | State, |
|
|
SEXP | Tout ) |
run simulations
Definition at line 105 of file generics.h.
105 {
106 SEXP out;
107 TYPE X = State;
108 PROTECT(Tout = AS_NUMERIC(Tout));
109 GetRNGstate();
110 X.valid();
111 X.play(*REAL(Tout));
112 PutRNGstate();
114 UNPROTECT(2);
115 return out;
116}
◆ serial()
template<class TYPE>
| SEXP serial |
( |
const TYPE & | X | ) |
|
binary serialization
Definition at line 28 of file generics.h.
28 {
29 SEXP out;
30 PROTECT(out = NEW_RAW(X.bytesize()));
31 X >> RAW(out);
32 UNPROTECT(1);
33 return out;
34}
◆ structure()
template<class TYPE>
| SEXP structure |
( |
const TYPE & | X | ) |
|
structure in R list format
Definition at line 50 of file generics.h.
50 {
51 return X.structure();
52}
◆ time()
Definition at line 22 of file generics.h.
22 {
23 return ScalarReal(X.time());
24}
◆ timezero()
template<class TYPE>
| SEXP timezero |
( |
TYPE & | X | ) |
|
Definition at line 17 of file generics.h.
17 {
18 return ScalarReal(X.timezero());
19}
◆ yaml()
template<class TYPE>
| SEXP yaml |
( |
const TYPE & | X | ) |
|
human/machine readable output
Definition at line 38 of file generics.h.
38 {
39 return mkString(X.yaml().c_str());
40}