[Pomp-commits] r681 - in pkg/pomp: . R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 25 23:50:47 CEST 2012


Author: kingaa
Date: 2012-04-25 23:50:46 +0200 (Wed, 25 Apr 2012)
New Revision: 681

Modified:
   pkg/pomp/NAMESPACE
   pkg/pomp/R/trajectory-pomp.R
   pkg/pomp/src/trajectory.c
Log:
- put in a routine to reset external variables after deSolve call


Modified: pkg/pomp/NAMESPACE
===================================================================
--- pkg/pomp/NAMESPACE	2012-04-25 21:48:17 UTC (rev 680)
+++ pkg/pomp/NAMESPACE	2012-04-25 21:50:46 UTC (rev 681)
@@ -18,7 +18,7 @@
           probe_acf,probe_ccf,
           probe_nlar,
           synth_loglik,
-          pomp_desolve_init,
+          pomp_desolve_setup,pomp_desolve_takedown,
           pomp_vf_eval,
           do_partrans,
           do_rprocess,

Modified: pkg/pomp/R/trajectory-pomp.R
===================================================================
--- pkg/pomp/R/trajectory-pomp.R	2012-04-25 21:48:17 UTC (rev 680)
+++ pkg/pomp/R/trajectory-pomp.R	2012-04-25 21:50:46 UTC (rev 681)
@@ -60,7 +60,7 @@
   } else if (type=="vectorfield") {
 
     skel <- get.pomp.fun(object at skeleton)
-    .Call(pomp_desolve_init,object,params,skel,statenames,nvar,nrep);
+    .Call(pomp_desolve_setup,object,params,skel,statenames,nvar,nrep);
 
     X <- try(
              ode(
@@ -75,6 +75,9 @@
                  ),
              silent=FALSE
              )
+
+    .Call(pomp_desolve_takedown)
+
     if (inherits(X,'try-error'))
       stop("trajectory error: error in ODE integrator",call.=FALSE)
     if (attr(X,'istate')[1]!=2)

Modified: pkg/pomp/src/trajectory.c
===================================================================
--- pkg/pomp/src/trajectory.c	2012-04-25 21:48:17 UTC (rev 680)
+++ pkg/pomp/src/trajectory.c	2012-04-25 21:50:46 UTC (rev 681)
@@ -113,16 +113,25 @@
 
 #define COMMON(X)    (_pomp_vf_eval_common.X)
 
-void pomp_desolve_init (SEXP object, SEXP params, SEXP fun, SEXP statenames, SEXP nvar, SEXP nrep) {
+void pomp_desolve_setup (SEXP object, SEXP params, SEXP fun, SEXP statenames, SEXP nvar, SEXP nrep) {
   COMMON(object) = object;
   COMMON(params) = params;
   COMMON(skelfun) = fun;
   COMMON(xnames) = statenames;
-  COMMON(xdim)[0] = INTEGER(AS_INTEGER(nvar))[0];
-  COMMON(xdim)[1] = INTEGER(AS_INTEGER(nrep))[0];
+  COMMON(xdim)[0] = *INTEGER(AS_INTEGER(nvar));
+  COMMON(xdim)[1] = *INTEGER(AS_INTEGER(nrep));
   COMMON(xdim)[2] = 1;
 }
 
+void pomp_desolve_takedown (void) {
+  COMMON(object) = R_NilValue;
+  COMMON(params) = R_NilValue;
+  COMMON(skelfun) = R_NilValue;
+  COMMON(xnames) = R_NilValue;
+  COMMON(xdim)[0] = 0;
+  COMMON(xdim)[1] = 0;
+  COMMON(xdim)[2] = 0;
+}
 
 void pomp_vf_eval (int *neq, double *t, double *y, double *ydot, double *yout, int *ip) 
 {



More information about the pomp-commits mailing list