search for: prod_real

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

2005 Oct 03
1
storage.mode, C data types and speed
...t;- storage.mode(nv) <- "double" > for(i in 1:3) {print(system.time(.Call("prod_integer", X, M, v, a, nm, nv)))} [1] 0 0 0 NA NA [1] 0 0 0 NA NA [1] 0 0 0 NA NA If on the other hand I use REAL instead of INTEGER in my C code: # include <Rinternals.h> SEXP prod_real(SEXP X, SEXP M, SEXP v, SEXP a, SEXP nm, SEXP nv) { int i = REAL(a)[0], i1 = 0, i2 = 0; for ( ; i1 < REAL(nm)[0]; i2 = (++i2 == REAL(nv)[0]) ? 0 : i2) { REAL(X)[i++] = REAL(M)[i1++] * REAL(v)[i2]; } return(X); } The reverse is true: > storage.mode(a) <- storage.mode(nm) <...