search for: nbatch

Displaying 14 results from an estimated 14 matches for "nbatch".

Did you mean: batch
2019 Sep 23
2
What is the best way to loop over an ALTREP vector?
...acro, it seems redundant to define etype and vtype for they have to match > the type of the SEXP. I'm wondering if this is intentional? Will there be a > type-free macro in R in the future? Here is a simple type-free macro I'm > using. > > #define type_free_iter(sx, ptr, ind, nbatch,expr)\ > > switch(TYPEOF(sx)){\ > > case INTSXP:\ > > ITERATE_BY_REGION(sx, ptr, ind, nbatch, int, INTEGER, expr);\ > > break; \ > > case REALSXP:\ > > ITERATE_BY_REGION(sx, ptr, ind, nbatch, double, REAL, expr);\ > > break; \ &g...
2019 Aug 28
3
What is the best way to loop over an ALTREP vector?
Hi devel team, I'm working on C/C++ level ALTREP compatibility for a package. The package previously used pointers to access the data of a SEXP, so it would not work for some ALTREP objects which do not have a pointer. I plan to rewrite the code and use functions like get_elt, get_region, and get_subset to access the values of a vector, so I have a few questions for ALTREP: 1. Since an
2019 Sep 23
0
What is the best way to loop over an ALTREP vector?
...first argument in the macro, it seems redundant to define etype and vtype for they have to match the type of the SEXP. I'm wondering if this is intentional? Will there be a type-free macro in R in the future? Here is a simple type-free macro I'm using. #define type_free_iter(sx, ptr, ind, nbatch,expr)\ switch(TYPEOF(sx)){\ case INTSXP:\ ITERATE_BY_REGION(sx, ptr, ind, nbatch, int, INTEGER, expr);\ break; \ case REALSXP:\ ITERATE_BY_REGION(sx, ptr, ind, nbatch, double, REAL, expr);\ break; \ case LGLSXP:\ ITERATE_BY_REGION(sx, ptr, ind, nbatch, in...
2019 Sep 24
2
What is the best way to loop over an ALTREP vector?
...they have to > match > >> the type of the SEXP. I'm wondering if this is intentional? Will there > be a > >> type-free macro in R in the future? Here is a simple type-free macro I'm > >> using. > >> > >> #define type_free_iter(sx, ptr, ind, nbatch,expr)\ > >> > >> switch(TYPEOF(sx)){\ > >> > >> case INTSXP:\ > >> > >> ITERATE_BY_REGION(sx, ptr, ind, nbatch, int, INTEGER, expr);\ > >> > >> break; \ > >> > >> case REALSXP:\ > >> >...
2019 Sep 24
0
What is the best way to loop over an ALTREP vector?
...ant to define etype and vtype for they have to match >> the type of the SEXP. I'm wondering if this is intentional? Will there be a >> type-free macro in R in the future? Here is a simple type-free macro I'm >> using. >> >> #define type_free_iter(sx, ptr, ind, nbatch,expr)\ >> >> switch(TYPEOF(sx)){\ >> >> case INTSXP:\ >> >> ITERATE_BY_REGION(sx, ptr, ind, nbatch, int, INTEGER, expr);\ >> >> break; \ >> >> case REALSXP:\ >> >> ITERATE_BY_REGION(sx, ptr, ind, nbatch,...
2019 May 01
3
anyNA() performance on vectors of POSIXct
...ot;), e0)); SEXP res = PROTECT(eval(e, env)); int ans = asLogical(res); UNPROTECT(3); return ans == 1; // so NA answer is false. } R_xlen_t i, n = xlength(x); switch (xT) { case REALSXP: { if(REAL_NO_NA(x)) return FALSE; ITERATE_BY_REGION(x, xD, i, nbatch, double, REAL, { for (int k = 0; k < nbatch; k++) if (ISNAN(xD[k])) return TRUE; }); break; } [[alternative HTML version deleted]]
2019 Oct 23
2
Unexpected behavior when using macro to loop over vector
...R_xlen_t nb = __ibr_n__; \ for (R_xlen_t idx = strt; idx < __ibr_n__; idx += nb) { \ expr \ } \ } \ else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ strt, nfull, expr); \ } while (0) // [[Rcpp::export]] void C_testPrint(SEXP x) { ITERATE_BY_REGION_PARTIAL(x, ptr, idx, nbatch, double, REAL, 1, 4, { for (R_xlen_t i = 0; i < nbatch; i++) Rprintf("idx: %lld, i: %lld, ptr:%f\n", idx, i, ptr[i]); }); } ``` The function C_testPrint loops over its argument x and prints out one value of x at each loop. The loop starts from the second element and ends in the fifth...
2019 Oct 25
2
Unexpected behavior when using macro to loop over vector
...nb) { \ >> expr \ >> ???? } \ >> } \ >> else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ >> strt, nfull, expr); \ >> ???? } while (0) >> // [[Rcpp::export]] >> void C_testPrint(SEXP x) { >> ITERATE_BY_REGION_PARTIAL(x, ptr, idx, nbatch, double, REAL, 1, 4, { >> for (R_xlen_t i = 0; i < nbatch; i++) >> Rprintf("idx: %lld, i: %lld, ptr:%f\n", idx, i, ptr[i]); > > You need to index "ptr" by "idx + i", not by "i". Have a look at how > the macros are used in R, e.g. prin...
2009 Sep 06
2
question about ... passed to two different functions
...eta))) logq <- ifelse(eta < 0, - log1p(exp(eta)), - eta - log1p(exp(- eta))) logl <- sum(logp[y == 1]) + sum(logq[y == 0]) val <- logl - sum(beta^2) / 2 return(val) } beta.initial <- as.vector(out$coefficients) out <- metrop(ludfun, initial = beta.initial, nbatch = 20, blen = 10, nspac = 5, scale = 0.56789) ### Works fine. Here are the Monte Carlo estimates of the posterior ### means for each parameter with Monte Carlo standard errors. apply(out$batch, 2, mean) sqrt(apply(out$batch, 2, function(x) initseq(x)$var.con) / out$nbatch) ### Now supp...
2019 Sep 04
0
[ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?
...1, SORTED_INCR_NA_1ST = 2, KNOWN_UNSORTED = 0}; The macro names are pretty self-explanatory. The current implementation only supports the ascending sort. 2. For anyNA, it goes to(Real SEXP) ===========coerce.c=========== if(REAL_NO_NA(x)) return FALSE; ITERATE_BY_REGION(x, xD, i, nbatch, double, REAL, { for (int k = 0; k < nbatch; k++) if (ISNAN(xD[k])) return TRUE; }); ===========altrep.c=========== int REAL_NO_NA(SEXP x) { return ALTREP(x) ? ALTREAL_DISPATCH(No_NA, x) : 0; } If the argument x is not an ALTREP, the function will return 0, and a default method will...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...x = strt; idx < __ibr_n__; idx += nb) { \ > expr \ > } \ > } \ > else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ > strt, nfull, expr); \ > } while (0) > // [[Rcpp::export]] > void C_testPrint(SEXP x) { > ITERATE_BY_REGION_PARTIAL(x, ptr, idx, nbatch, double, REAL, 1, 4, { > for (R_xlen_t i = 0; i < nbatch; i++) > Rprintf("idx: %lld, i: %lld, ptr:%f\n", idx, i, ptr[i]); You need to index "ptr" by "idx + i", not by "i". Have a look at how the macros are used in R, e.g. printvector.c. Best, Toma...
2019 May 21
0
anyNA() performance on vectors of POSIXct
...nt ans = asLogical(res); > UNPROTECT(3); > return ans == 1; // so NA answer is false. > } > > R_xlen_t i, n = xlength(x); > switch (xT) { > case REALSXP: > { > if(REAL_NO_NA(x)) > return FALSE; > ITERATE_BY_REGION(x, xD, i, nbatch, double, REAL, { > for (int k = 0; k < nbatch; k++) > if (ISNAN(xD[k])) > return TRUE; > }); > break; > } >
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...} \ > >> } \ > >> else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ > >> strt, nfull, expr); \ > >> } while (0) > >> // [[Rcpp::export]] > >> void C_testPrint(SEXP x) { > >> ITERATE_BY_REGION_PARTIAL(x, ptr, idx, nbatch, double, REAL, 1, 4, { > >> for (R_xlen_t i = 0; i < nbatch; i++) > >> Rprintf("idx: %lld, i: %lld, ptr:%f\n", idx, i, ptr[i]); > > > > You need to index "ptr" by "idx + i", not by "i". Have a look at how > > the macros...
2019 Jan 05
1
unsorted - suggestion for performance improvement and ALTREP support for POSIXct
I believe the performance of isUnsorted() in sort.c could be improved by calling REAL() once (outside of the for loop), rather than calling it twice inside the loop. As an aside, it is implemented in the faster way in doSort() (sort.c line 401). The example below shows the performance improvement for a vectors of double of moving REAL() outside the for loop. # example as implemented in