phylopomp
Phylodynamics for POMPs
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 GENEALFN(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 timezero (TYPE &X)
 
template<class TYPE >
SEXP time (TYPE &X)
 
template<class TYPE >
SEXP serial (const TYPE &X)
 binary serialization More...
 
template<class TYPE >
SEXP yaml (const TYPE &X)
 human/machine readable output More...
 
template<class TYPE >
SEXP describe (const TYPE &X)
 human readable output More...
 
template<class TYPE >
SEXP structure (const TYPE &X)
 structure in R list format More...
 
template<class TYPE >
SEXP newick (const TYPE &X)
 tree in newick format More...
 
template<class TYPE >
SEXP lineage_count (const TYPE &G)
 number of lineages through time More...
 
template<class TYPE >
SEXP gendat (const TYPE &G)
 data-frame format More...
 
template<class TYPE >
SEXP make (SEXP Params, SEXP IVPs, SEXP T0)
 initialization More...
 
template<class TYPE >
SEXP revive (SEXP State, SEXP Params)
 refresh parameters More...
 
template<class TYPE >
SEXP run (SEXP State, SEXP Tout)
 run simulations More...
 
template<class TYPE >
SEXP genealogy (SEXP State)
 extract the bare genealogy More...
 

Macro Definition Documentation

◆ GENEALFN

#define GENEALFN (   X,
  TYPE 
)
Value:
SEXP geneal ## X (SEXP State) { \
return genealogy<TYPE>(State); \
} \

Definition at line 141 of file generics.h.

◆ GENERICS

#define GENERICS (   X,
  TYPE 
)
Value:
extern "C" { \
MAKEFN(X,TYPE) \
REVIVEFN(X,TYPE) \
RUNFN(X,TYPE) \
GENEALFN(X,TYPE) \
YAMLFN(X,TYPE) \
\
} \
#define GENEALFN(X, TYPE)
Definition: generics.h:141
#define MAKEFN(X, TYPE)
Definition: generics.h:129
#define RUNFN(X, TYPE)
Definition: generics.h:137
#define YAMLFN(X, TYPE)
Definition: generics.h:145
#define REVIVEFN(X, TYPE)
Definition: generics.h:133

Definition at line 149 of file generics.h.

◆ 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:74

Definition at line 129 of file generics.h.

◆ 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:93

Definition at line 133 of file generics.h.

◆ 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:105

Definition at line 137 of file generics.h.

◆ 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:38

Definition at line 145 of file generics.h.

Function Documentation

◆ 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 }
Here is the caller graph for this function:

◆ 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
Definition: generics.h:28
Here is the call graph for this function:

◆ 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 }
Here is the caller graph for this function:

◆ 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();
86  PROTECT(o = serial(X));
87  UNPROTECT(4);
88  return o;
89 }
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)

tree in newick format

Definition at line 56 of file generics.h.

56  {
57  return mkString(X.newick().c_str());
58 }
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 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));
98  PROTECT(o = serial(X));
99  UNPROTECT(2);
100  return o;
101 }
Here is the call graph for this function:

◆ 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();
113  PROTECT(out = serial(X));
114  UNPROTECT(2);
115  return out;
116 }
Here is the call graph for this function:

◆ 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 }
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 50 of file generics.h.

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

◆ time()

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

Definition at line 22 of file generics.h.

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

◆ timezero()

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

Definition at line 17 of file generics.h.

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

◆ 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 }