#include #include static void addone(double *x, int *nx, double *val, int *nv) { if (nx[0] == nv[0]) { int n, i; n = nx[0]; for (i = 0; i < n; i++) val[i] = x[i] + 1.0; } else error("argument and value lengths do not match."); } SEXP addoneDotCall(SEXP x) { int n; SEXP val; if (TYPEOF(x) != REALSXP) error("x must be a numeric vector"); n = LENGTH(x); PROTECT(val = allocVector(REALSXP, n)); addone(REAL(x), &n, REAL(val), &n); UNPROTECT(1); return val; }