[Pomp-commits] r301 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 24 20:04:54 CEST 2010
Author: kingaa
Date: 2010-08-24 20:04:54 +0200 (Tue, 24 Aug 2010)
New Revision: 301
Modified:
pkg/R/euler.R
pkg/R/plugins.R
pkg/R/pomp-fun.R
pkg/R/pomp.R
pkg/man/plugins.Rd
Log:
- modify 'pomp.fun' so that the prototype is passed as an unevaluated call rather than as a character string (thus avoiding issues with escaped characters"
- modify the plug-in 'discrete.time.sim' so that delta.t=1 is enforced
Modified: pkg/R/euler.R
===================================================================
--- pkg/R/euler.R 2010-08-24 13:09:37 UTC (rev 300)
+++ pkg/R/euler.R 2010-08-24 18:04:54 UTC (rev 301)
@@ -10,7 +10,7 @@
efun <- pomp.fun(
f=step.fun,
PACKAGE=PACKAGE,
- proto="step.fun(x,t,params,delta.t,...)"
+ proto=quote(step.fun(x,t,params,delta.t,...))
)
.Call(
euler_model_simulator,
@@ -42,7 +42,7 @@
efun <- pomp.fun(
f=step.fun,
PACKAGE=PACKAGE,
- proto="step.fun(x,t,params,delta.t,...)"
+ proto=quote(step.fun(x,t,params,delta.t,...))
)
.Call(
euler_model_simulator,
@@ -74,7 +74,7 @@
efun <- pomp.fun(
f=dens.fun,
PACKAGE=PACKAGE,
- proto="dens.fun(x1,x2,t1,t2,params,...)"
+ proto=quote(dens.fun(x1,x2,t1,t2,params,...))
)
.Call(
euler_model_density,
Modified: pkg/R/plugins.R
===================================================================
--- pkg/R/plugins.R 2010-08-24 13:09:37 UTC (rev 300)
+++ pkg/R/plugins.R 2010-08-24 18:04:54 UTC (rev 301)
@@ -2,7 +2,7 @@
efun <- pomp.fun(
f=step.fun,
PACKAGE=PACKAGE,
- proto="step.fun(x,t,params,delta.t,...)"
+ proto=quote(step.fun(x,t,params,delta.t,...))
)
function (xstart, times, params, ...,
statenames = character(0),
@@ -29,11 +29,11 @@
}
}
-discrete.time.sim <- function (step.fun, delta.t = 1, PACKAGE) {
+discrete.time.sim <- function (step.fun, PACKAGE) {
efun <- pomp.fun(
f=step.fun,
PACKAGE=PACKAGE,
- proto="step.fun(x,t,params,delta.t,...)"
+ proto=quote(step.fun(x,t,params,...))
)
function (xstart, times, params, ...,
statenames = character(0),
@@ -47,7 +47,7 @@
xstart=xstart,
times=times,
params=params,
- dt=delta.t,
+ dt=1,
method=0L,
statenames=statenames,
paramnames=paramnames,
@@ -64,7 +64,7 @@
efun <- pomp.fun(
f=step.fun,
PACKAGE=PACKAGE,
- proto="step.fun(x,t,params,delta.t,...)"
+ proto=quote(step.fun(x,t,params,delta.t,...))
)
function (xstart, times, params, ...,
statenames = character(0),
@@ -95,7 +95,7 @@
efun <- pomp.fun(
f=dens.fun,
PACKAGE=PACKAGE,
- proto="dens.fun(x1,x2,t1,t2,params,...)"
+ proto=quote(dens.fun(x1,x2,t1,t2,params,...))
)
function (x, times, params, ...,
statenames = character(0),
@@ -131,7 +131,7 @@
efun <- pomp.fun(
f=rate.fun,
PACKAGE=PACKAGE,
- proto="rate.fun(j,x,t,params,...)"
+ proto=quote(rate.fun(j,x,t,params,...))
)
function (xstart, times, params,
statenames = character(0),
Modified: pkg/R/pomp-fun.R
===================================================================
--- pkg/R/pomp-fun.R 2010-08-24 13:09:37 UTC (rev 300)
+++ pkg/R/pomp-fun.R 2010-08-24 18:04:54 UTC (rev 301)
@@ -15,7 +15,9 @@
PACKAGE <- character(0)
if (is.function(f)) {
if (!is.null(proto)) {
- prototype <- strsplit(as.character(proto),split="\\(|\\)|\\,")
+ if (!is.call(proto))
+ stop(sQuote("proto")," must be an unevaluated call")
+ prototype <- as.character(proto)
fname <- prototype[1]
args <- prototype[-1]
if (!all(args%in%names(formals(f))))
Modified: pkg/R/pomp.R
===================================================================
--- pkg/R/pomp.R 2010-08-24 13:09:37 UTC (rev 300)
+++ pkg/R/pomp.R 2010-08-24 18:04:54 UTC (rev 301)
@@ -100,12 +100,12 @@
skeleton <- pomp.fun(f=function(x,t,params,covars,...)stop(sQuote("skeleton")," not specified"))
} else { # skeleton is a vectorfield (ordinary differential equation)
skeleton.type <- "vectorfield"
- skeleton <- pomp.fun(f=skeleton.vectorfield,PACKAGE=PACKAGE,proto="skeleton.vectorfield(x,t,params,...)")
+ skeleton <- pomp.fun(f=skeleton.vectorfield,PACKAGE=PACKAGE,proto=quote(skeleton.vectorfield(x,t,params,...)))
}
} else {
if (missing(skeleton.vectorfield)) { # skeleton is a map (discrete-time system)
skeleton.type <- "map"
- skeleton <- pomp.fun(f=skeleton.map,PACKAGE=PACKAGE,proto="skeleton.map(x,t,params,...)")
+ skeleton <- pomp.fun(f=skeleton.map,PACKAGE=PACKAGE,proto=quote(skeleton.map(x,t,params,...)))
} else { # a dynamical system cannot be both a map and a vectorfield
stop("pomp error: it is not permitted to specify both ",sQuote("skeleton.map")," and ",sQuote("skeleton.vectorfield"))
}
@@ -128,8 +128,8 @@
call.=TRUE
)
- rmeasure <- pomp.fun(f=rmeasure,PACKAGE=PACKAGE,proto="rmeasure(x,t,params,...)")
- dmeasure <- pomp.fun(f=dmeasure,PACKAGE=PACKAGE,proto="dmeasure(y,x,t,params,log,...)")
+ rmeasure <- pomp.fun(f=rmeasure,PACKAGE=PACKAGE,proto=quote(rmeasure(x,t,params,...)))
+ dmeasure <- pomp.fun(f=dmeasure,PACKAGE=PACKAGE,proto=quote(dmeasure(y,x,t,params,log,...)))
if (!is.function(initializer))
stop(
Modified: pkg/man/plugins.Rd
===================================================================
--- pkg/man/plugins.Rd 2010-08-24 13:09:37 UTC (rev 300)
+++ pkg/man/plugins.Rd 2010-08-24 18:04:54 UTC (rev 301)
@@ -13,7 +13,7 @@
\usage{
onestep.sim(step.fun, PACKAGE)
euler.sim(step.fun, delta.t, PACKAGE)
-discrete.time.sim(step.fun, delta.t = 1, PACKAGE)
+discrete.time.sim(step.fun, PACKAGE)
gillespie.sim(rate.fun, v, d, PACKAGE)
onestep.dens(dens.fun, PACKAGE)
}
@@ -68,7 +68,7 @@
\code{euler.sim} is appropriate when one cannot do this but can compute the change in state via a sequence of smaller steps.
This is desirable, for example, if one is simulating a continuous time process but is willing to approximate it using an Euler approach.
\code{discrete.time.sim} is appropriate when the process evolves in discrete time.
- In this case, it is assumed that the intervals between observations are integer multiples of \code{delta.t}.
+ In this case, it is assumed that the intervals between observations are integers.
Beware, however: this assumption is not checked.
To use \code{euler.sim} or \code{discrete.time.sim}, you must write a function \code{step.fun} that will take a single Euler step, of size at most \code{delta.t}.
More information about the pomp-commits
mailing list