search for: prod_integer

Displaying 1 result from an estimated 1 matches for "prod_integer".

2005 Oct 03
1
storage.mode, C data types and speed
...0*nr #index of X indicating where to start replacing values nm <- length(M) nv <- length(v) I would have thought I wanted storage.mode(a) <- storage.mode(nm) <- storage.mode(nv) <- "integer" to go with the following C code # include <Rinternals.h> SEXP prod_integer(SEXP X, SEXP M, SEXP v, SEXP a, SEXP nm, SEXP nv) { int i = INTEGER(a)[0], i1 = 0, i2 = 0; for ( ; i1 < INTEGER(nm)[0]; i2 = (++i2 == INTEGER(nv)[0]) ? 0 : i2) { REAL(X)[i++] = REAL(M)[i1++] * REAL(v)[i2]; } return(X); } Running this is R gives the following timings on my PC >...