[Pomp-commits] r305 - in pkg: data inst inst/data-R inst/doc inst/examples src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 24 22:51:16 CEST 2010
Author: kingaa
Date: 2010-08-24 22:51:15 +0200 (Tue, 24 Aug 2010)
New Revision: 305
Modified:
pkg/data/euler.sir.rda
pkg/data/gillespie.sir.rda
pkg/data/ou2.rda
pkg/data/ricker.rda
pkg/inst/ChangeLog
pkg/inst/data-R/euler.sir.R
pkg/inst/data-R/gillespie.sir.R
pkg/inst/data-R/ou2.R
pkg/inst/data-R/ricker.R
pkg/inst/doc/advanced_topics_in_pomp.Rnw
pkg/inst/doc/advanced_topics_in_pomp.pdf
pkg/inst/doc/intro_to_pomp.pdf
pkg/inst/examples/sir.R
pkg/inst/examples/sir.c
pkg/src/cholmodel.c
pkg/src/ou2.c
pkg/src/ricker.c
pkg/src/sir.c
Log:
- change names of C routines to keep namespace open (prepend C symbols in the package with "_")
Modified: pkg/data/euler.sir.rda
===================================================================
(Binary files differ)
Modified: pkg/data/gillespie.sir.rda
===================================================================
(Binary files differ)
Modified: pkg/data/ou2.rda
===================================================================
(Binary files differ)
Modified: pkg/data/ricker.rda
===================================================================
(Binary files differ)
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/ChangeLog 2010-08-24 20:51:15 UTC (rev 305)
@@ -1,5 +1,6 @@
2010-08-24 kingaa
+ * [r304] inst/ChangeLog: - update changelog
* [r303] DESCRIPTION, data/dacca.rda, data/euler.sir.rda,
data/gillespie.sir.rda, data/ou2.rda, data/ricker.rda,
inst/ChangeLog, inst/data-R/ricker.R,
Modified: pkg/inst/data-R/euler.sir.R
===================================================================
--- pkg/inst/data-R/euler.sir.R 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/data-R/euler.sir.R 2010-08-24 20:51:15 UTC (rev 305)
@@ -9,13 +9,13 @@
times="time",
t0=0,
rprocess=euler.sim(
- step.fun="sir_euler_simulator",
+ step.fun="_sir_euler_simulator",
delta.t=1/52/20,
PACKAGE="pomp"
),
- skeleton.vectorfield="sir_ODE",
- rmeasure="sir_binom_rmeasure",
- dmeasure="sir_binom_dmeasure",
+ skeleton.vectorfield="_sir_ODE",
+ rmeasure="_sir_binom_rmeasure",
+ dmeasure="_sir_binom_dmeasure",
PACKAGE="pomp",
obsnames = c("reports"),
statenames=c("S","I","R","cases","W"),
Modified: pkg/inst/data-R/gillespie.sir.R
===================================================================
--- pkg/inst/data-R/gillespie.sir.R 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/data-R/gillespie.sir.R 2010-08-24 20:51:15 UTC (rev 305)
@@ -28,7 +28,7 @@
times="time",
t0=0,
rprocess=gillespie.sim(
- rate.fun="sir_rates",
+ rate.fun="_sir_rates",
PACKAGE="pomp",
v=cbind(
birth=c(1,0,0,1,0),
Modified: pkg/inst/data-R/ou2.R
===================================================================
--- pkg/inst/data-R/ou2.R 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/data-R/ou2.R 2010-08-24 20:51:15 UTC (rev 305)
@@ -17,7 +17,7 @@
## C uses zero-based indexing!
parindex <- match(paramnames,rownames(params))-1
array(
- .C("ou2_adv",
+ .C("_ou2_adv",
X = double(nvar*nrep*ntimes),
xstart = as.double(xstart),
par = as.double(params),
@@ -39,7 +39,7 @@
ntimes <- length(times)
parindex <- match(paramnames,rownames(params))-1
array(
- .C("ou2_pdf",
+ .C("_ou2_pdf",
d = double(nrep*(ntimes-1)),
X = as.double(x),
par = as.double(params),
@@ -54,8 +54,8 @@
dim=c(nrep,ntimes-1)
)
},
- dmeasure = "ou2_normal_dmeasure",
- rmeasure = "ou2_normal_rmeasure",
+ dmeasure = "_ou2_normal_dmeasure",
+ rmeasure = "_ou2_normal_rmeasure",
skeleton.map = function (x, t, params, ...) {
with(
as.list(c(x,params)),
Modified: pkg/inst/data-R/ricker.R
===================================================================
--- pkg/inst/data-R/ricker.R 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/data-R/ricker.R 2010-08-24 20:51:15 UTC (rev 305)
@@ -6,11 +6,11 @@
times="time",
t0=0,
rprocess=discrete.time.sim(
- step.fun="ricker_simulator"
+ step.fun="_ricker_simulator"
),
- rmeasure="poisson_rmeasure",
- dmeasure="poisson_dmeasure",
- skeleton.map="ricker_skeleton",
+ rmeasure="_ricker_poisson_rmeasure",
+ dmeasure="_ricker_poisson_dmeasure",
+ skeleton.map="_ricker_skeleton",
paramnames=c("log.r","log.sigma","log.phi"),
statenames=c("N","e"),
obsnames=c("y")
Modified: pkg/inst/doc/advanced_topics_in_pomp.Rnw
===================================================================
--- pkg/inst/doc/advanced_topics_in_pomp.Rnw 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/doc/advanced_topics_in_pomp.Rnw 2010-08-24 20:51:15 UTC (rev 305)
@@ -88,7 +88,7 @@
## C uses zero-based indexing!
parindex <- match(paramnames,rownames(params))-1
array(
- .C("ou2_adv",
+ .C("_ou2_adv",
X = double(nvar*nrep*ntimes),
xstart = as.double(xstart),
par = as.double(params),
@@ -113,7 +113,7 @@
ntimes <- length(times)
parindex <- match(paramnames,rownames(params))-1
array(
- .C("ou2_pdf",
+ .C("_ou2_pdf",
d = double(nrep*(ntimes-1)),
X = as.double(x),
par = as.double(params),
@@ -142,8 +142,8 @@
t0=0,
rprocess = ou2.rprocess,
dprocess = ou2.dprocess,
- dmeasure = "ou2_normal_dmeasure",
- rmeasure = "ou2_normal_rmeasure",
+ dmeasure = "_ou2_normal_dmeasure",
+ rmeasure = "_ou2_normal_rmeasure",
paramnames=c(
"alpha.1","alpha.2","alpha.3","alpha.4",
"sigma.1","sigma.2","sigma.3",
@@ -208,14 +208,14 @@
t0=0,
## native routine for the process simulator:
rprocess=euler.sim(
- step.fun="sir_euler_simulator",
+ step.fun="_sir_euler_simulator",
delta.t=1/52/20
),
## native routine for the skeleton:
- skeleton.vectorfield="sir_ODE",
+ skeleton.vectorfield="_sir_ODE",
## binomial measurement model:
- rmeasure="sir_binom_rmeasure",
- dmeasure="sir_binom_dmeasure",
+ rmeasure="_sir_binom_rmeasure",
+ dmeasure="_sir_binom_dmeasure",
## name of the shared-object library containing the native routines:
PACKAGE="pomp",
## the order of the observable assumed in the native routines:
@@ -243,7 +243,7 @@
}
) -> sir
@
-The source code for the native routines \verb+sir_euler_simulator+, \verb+sir_ODE+, \verb+sir_binom_rmeasure+, and \verb+sir_binom_dmeasure+ is provided with the package (in the \code{examples} directory).
+The source code for the native routines \verb+_sir_euler_simulator+, \verb+_sir_ODE+, \verb+_sir_binom_rmeasure+, and \verb+_sir_binom_dmeasure+ is provided with the package (in the \code{examples} directory).
To see the source code, do
<<view-sir-source,eval=F>>=
edit(file=system.file("examples/sir.c",package="pomp"))
Modified: pkg/inst/doc/advanced_topics_in_pomp.pdf
===================================================================
(Binary files differ)
Modified: pkg/inst/doc/intro_to_pomp.pdf
===================================================================
(Binary files differ)
Modified: pkg/inst/examples/sir.R
===================================================================
--- pkg/inst/examples/sir.R 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/examples/sir.R 2010-08-24 20:51:15 UTC (rev 305)
@@ -39,12 +39,12 @@
times="time",
t0=0,
rprocess=euler.sim(
- step.fun="sir_euler_simulator", # native routine for the simulation step
+ step.fun="_sir_euler_simulator", # native routine for the simulation step
delta.t=1/52/20
),
- skeleton.vectorfield="sir_ODE", # native routine for the skeleton
- rmeasure="sir_binom_rmeasure", # binomial measurement model
- dmeasure="sir_binom_dmeasure", # binomial measurement model
+ skeleton.vectorfield="_sir_ODE", # native routine for the skeleton
+ rmeasure="_sir_binom_rmeasure", # binomial measurement model
+ dmeasure="_sir_binom_dmeasure", # binomial measurement model
PACKAGE="sir", ## name of the shared-object library
## the order of the observables assumed in the native routines:
obsnames="reports",
Modified: pkg/inst/examples/sir.c
===================================================================
--- pkg/inst/examples/sir.c 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/inst/examples/sir.c 2010-08-24 20:51:15 UTC (rev 305)
@@ -43,15 +43,15 @@
#define REPORTS (y[obsindex[0]])
-void sir_binom_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _sir_binom_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
*lik = dbinom(REPORTS,CASE,exp(LOGRHO),give_log);
}
-void sir_binom_rmeasure (double *y, double *x, double *p,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _sir_binom_rmeasure (double *y, double *x, double *p,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
REPORTS = rbinom(CASE,exp(LOGRHO));
}
@@ -61,10 +61,10 @@
// forced transmission (basis functions passed as covariates)
// constant population size as a parameter
// environmental stochasticity on transmission
-void sir_euler_simulator (double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar,
- double t, double dt)
+void _sir_euler_simulator (double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar,
+ double t, double dt)
{
int nrate = 6;
double rate[nrate]; // transition rates
@@ -139,9 +139,9 @@
#define DRDT (f[stateindex[2]])
#define DCDT (f[stateindex[3]])
-void sir_ODE (double *f, double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar, double t)
+void _sir_ODE (double *f, double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar, double t)
{
int nrate = 6;
double rate[nrate]; // transition rates
@@ -223,9 +223,9 @@
#define POPN (x[stateindex[3]]) // population size
#define CASE (x[stateindex[4]]) // accumulated cases
-double sir_rates (int j, double t, double *x, double *p,
- int *stateindex, int *parindex, int *covindex,
- int ncovar, double *covar) {
+double _sir_rates (int j, double t, double *x, double *p,
+ int *stateindex, int *parindex, int *covindex,
+ int ncovar, double *covar) {
double beta;
double rate = 0.0;
int nseas = (int) NBASIS; // number of seasonal basis functions
@@ -298,9 +298,9 @@
// forced transmission (basis functions passed as covariates)
// constant population size as a parameter
// environmental stochasticity on transmission
-void sir_euler_density (double *f, double *x1, double *x2, double t1, double t2, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar)
+void _sir_euler_density (double *f, double *x1, double *x2, double t1, double t2, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar)
{
int nrate = 6;
double rate[nrate]; // transition rates
Modified: pkg/src/cholmodel.c
===================================================================
--- pkg/src/cholmodel.c 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/src/cholmodel.c 2010-08-24 20:51:15 UTC (rev 305)
@@ -71,9 +71,9 @@
// truncation is not used
// instead, particles with negative states are killed
void _cholmodel_one (double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar,
- double t, double dt)
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar,
+ double t, double dt)
{ // implementation of the SIRS cholera model
int nrstage = (int) NRSTAGE;
int nbasis = (int) NBASIS;
Modified: pkg/src/ou2.c
===================================================================
--- pkg/src/ou2.c 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/src/ou2.c 2010-08-24 20:51:15 UTC (rev 305)
@@ -8,14 +8,14 @@
// prototypes
-void ou2_normal_rmeasure (double *y, double *x, double *p,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovar, double *covar, double t);
-void ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int covdim, double *covar, double t);
-void ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex);
-void ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log);
+void _ou2_normal_rmeasure (double *y, double *x, double *p,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovar, double *covar, double t);
+void _ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int covdim, double *covar, double t);
+void _ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex);
+void _ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log);
static void sim_ou2 (double *x,
double alpha1, double alpha2, double alpha3, double alpha4,
double sigma1, double sigma2, double sigma3);
@@ -33,7 +33,7 @@
// advance the matrix of particles from times[0] to the other times given
// it is assumed that the times are consecutive (FIX THIS!)
-void ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex)
+void _ou2_adv (double *x, double *xstart, double *par, double *times, int *n, int *parindex)
{
int nvar = n[0], npar = n[1], nrep = n[2], ntimes = n[3];
double *xp, *pp;
@@ -56,7 +56,7 @@
}
// pdf of a single 2D OU transition
-void ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log)
+void _ou2_pdf (double *d, double *X, double *par, double *times, int *n, int *parindex, int *give_log)
{
int nvar = n[0], npar = n[1], nrep = n[2], ntimes = n[3];
double *x1, *x2, *pp;
@@ -88,9 +88,9 @@
#define Y2 (y[obsindex[1]])
// bivariate normal measurement error density
-void ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int covdim, double *covar, double t)
+void _ou2_normal_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int covdim, double *covar, double t)
{
double sd = fabs(TAU);
double f = 0.0;
@@ -100,10 +100,10 @@
}
// bivariate normal measurement error simulator
-void ou2_normal_rmeasure (double *y, double *x, double *p,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovar, double *covar,
- double t)
+void _ou2_normal_rmeasure (double *y, double *x, double *p,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovar, double *covar,
+ double t)
{
double sd = fabs(TAU);
Y1 = rnorm(X1,sd);
@@ -174,5 +174,3 @@
val = dnorm(eps[0],0.0,1.0,1)+dnorm(eps[1],0.0,1.0,1)-log(sigma1)-log(sigma3);
return ((give_log) ? val : exp(val));
}
-
-
Modified: pkg/src/ricker.c
===================================================================
--- pkg/src/ricker.c 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/src/ricker.c 2010-08-24 20:51:15 UTC (rev 305)
@@ -13,25 +13,25 @@
#define Y (y[obsindex[0]]) // observed population size
-void poisson_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _ricker_poisson_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
*lik = dpois(Y,exp(LOG_PHI)*N,give_log);
}
-void poisson_rmeasure (double *y, double *x, double *p,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _ricker_poisson_rmeasure (double *y, double *x, double *p,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
Y = rpois(exp(LOG_PHI)*N);
}
#undef Y
// Ricker model with log-normal process noise
-void ricker_simulator (double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar,
- double t, double dt)
+void _ricker_simulator (double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar,
+ double t, double dt)
{
double sigma = exp(LOG_SIGMA);
double e = (sigma > 0.0) ? rnorm(0,sigma) : 0.0;
@@ -39,9 +39,9 @@
E = e;
}
-void ricker_skeleton (double *f, double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar, double t)
+void _ricker_skeleton (double *f, double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar, double t)
{
f[0] = exp(LOG_R+log(N)-N);
f[1] = 0.0;
Modified: pkg/src/sir.c
===================================================================
--- pkg/src/sir.c 2010-08-24 18:35:18 UTC (rev 304)
+++ pkg/src/sir.c 2010-08-24 20:51:15 UTC (rev 305)
@@ -43,15 +43,15 @@
#define REPORTS (y[obsindex[0]])
-void sir_binom_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _sir_binom_dmeasure (double *lik, double *y, double *x, double *p, int give_log,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
*lik = dbinom(REPORTS,CASE,exp(LOGRHO),give_log);
}
-void sir_binom_rmeasure (double *y, double *x, double *p,
- int *obsindex, int *stateindex, int *parindex, int *covindex,
- int ncovars, double *covars, double t) {
+void _sir_binom_rmeasure (double *y, double *x, double *p,
+ int *obsindex, int *stateindex, int *parindex, int *covindex,
+ int ncovars, double *covars, double t) {
REPORTS = rbinom(CASE,exp(LOGRHO));
}
@@ -61,10 +61,10 @@
// forced transmission (basis functions passed as covariates)
// constant population size as a parameter
// environmental stochasticity on transmission
-void sir_euler_simulator (double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar,
- double t, double dt)
+void _sir_euler_simulator (double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar,
+ double t, double dt)
{
int nrate = 6;
double rate[nrate]; // transition rates
@@ -139,9 +139,9 @@
#define DRDT (f[stateindex[2]])
#define DCDT (f[stateindex[3]])
-void sir_ODE (double *f, double *x, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar, double t)
+void _sir_ODE (double *f, double *x, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar, double t)
{
int nrate = 6;
double rate[nrate]; // transition rates
@@ -223,9 +223,9 @@
#define POPN (x[stateindex[3]]) // population size
#define CASE (x[stateindex[4]]) // accumulated cases
-double sir_rates (int j, double t, double *x, double *p,
- int *stateindex, int *parindex, int *covindex,
- int ncovar, double *covar) {
+double _sir_rates (int j, double t, double *x, double *p,
+ int *stateindex, int *parindex, int *covindex,
+ int ncovar, double *covar) {
double beta;
double rate = 0.0;
int nseas = (int) NBASIS; // number of seasonal basis functions
@@ -298,9 +298,9 @@
// forced transmission (basis functions passed as covariates)
// constant population size as a parameter
// environmental stochasticity on transmission
-void sir_euler_density (double *f, double *x1, double *x2, double t1, double t2, const double *p,
- const int *stateindex, const int *parindex, const int *covindex,
- int covdim, const double *covar)
+void _sir_euler_density (double *f, double *x1, double *x2, double t1, double t2, const double *p,
+ const int *stateindex, const int *parindex, const int *covindex,
+ int covdim, const double *covar)
{
int nrate = 6;
double rate[nrate]; // transition rates
More information about the pomp-commits
mailing list