search for: c_routines

Displaying 2 results from an estimated 2 matches for "c_routines".

Did you mean: __routine
2005 Oct 12
1
Using matprod from array.c
...rod(SEXP M, SEXP v, SEXP nr, SEXP nc) { R_len_t nrm = INTEGER(nr)[0], ncm = INTEGER(nc)[0]; SEXP ans; PROTECT(ans = allocMatrix(REALSXP, nrm, 1)); matprod(REAL(M), nrm, ncm, REAL(v), ncm, 1, REAL(ans)); UNPROTECT(1); return(ans); } When I try to make the DLL I get the following D:\C_routines>RCMD SHLIB my_matprod.c making my_matprod.d from my_matprod.c gcc -IC:/R/tex/R-2.2.0/include -Wall -O2 -c my_matprod.c -o my_matprod.o ar cr my_matprod.a my_matprod.o ranlib my_matprod.a gcc --shared -s -o my_matprod.dll my_matprod.def my_matprod.a -LC:/R/tex/R-2. 2.0/src/gnuwin32 -lg2c...
2005 Oct 03
1
storage.mode, C data types and speed
...XP 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 > dyn.load("D:/C_routines/prod_integer") > for(i in 1:3) {print(system.time(.Call("prod_integer", X, M, v, a, nm, nv)))} [1] 0.17 0.00 0.18 NA NA [1] 0.18 0.00 0.17 NA NA [1] 0.15 0.00 0.17 NA NA But strangely (to me) if I change the storage mode of my integers to "double", I get &g...