From 013d1970a923fce1cf6002092010bbb2d59ce638 Mon Sep 17 00:00:00 2001 From: Duncan Temple Lang Date: Sat, 18 May 2019 17:01:47 -0700 Subject: [PATCH] equivalent .Call() version of the x + 1 routine --- dotC/src/dotCall.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 dotC/src/dotCall.c diff --git a/dotC/src/dotCall.c b/dotC/src/dotCall.c new file mode 100644 index 0000000..a00023e --- /dev/null +++ b/dotC/src/dotCall.c @@ -0,0 +1,16 @@ +#include + +SEXP +R_add1_2(SEXP x) +{ + int len = LENGTH(x) ; //Rf_length(x); + SEXP ans; + if(TYPEOF(x) != REALSXP) { + PROBLEM "wrong type" + ERROR; + } + ans = NEW_NUMERIC(len); + for(int i = 0; i < len; i++) + REAL(ans)[i] = REAL(x)[i] + 1; + return(ans); +}