[Blotter-commits] r1608 - pkg/quantstrat/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun May 4 16:32:35 CEST 2014
Author: bodanker
Date: 2014-05-04 16:32:35 +0200 (Sun, 04 May 2014)
New Revision: 1608
Modified:
pkg/quantstrat/src/firstCross.c
Log:
- patch firstCross to coerce to numeric, if necessary
Modified: pkg/quantstrat/src/firstCross.c
===================================================================
--- pkg/quantstrat/src/firstCross.c 2014-05-03 14:02:37 UTC (rev 1607)
+++ pkg/quantstrat/src/firstCross.c 2014-05-04 14:32:35 UTC (rev 1608)
@@ -3,7 +3,7 @@
SEXP firstCross(SEXP x, SEXP th, SEXP rel, SEXP start)
{
- int i, int_rel, int_start;
+ int i, int_rel, int_start, P=0;
double *real_x=NULL, real_th;
if(ncols(x) > 1)
@@ -11,6 +11,7 @@
/* this currently only works for real x and th arguments
* support for other types may be added later */
+ PROTECT(x = coerceVector(x, REALSXP)); P++;
real_th = asReal(th);
int_rel = asInteger(rel);
int_start = asInteger(start)-1;
@@ -49,6 +50,7 @@
default:
error("unsupported relationship operator");
}
+ UNPROTECT(P);
/* return number of observations if relationship is never TRUE */
return(ScalarInteger(nrows(x)));
}
More information about the Blotter-commits
mailing list