Displaying 4 results from an estimated 4 matches for "c_testprint".
2019 Oct 23
2
Unexpected behavior when using macro to loop over vector
...f (px != NULL) { \
R_xlen_t __ibr_n__ = strt + nfull; \
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 lo...
2019 Oct 25
2
Unexpected behavior when using macro to loop over vector
..._; \
>> ??? 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]);
>
> You need to index "ptr" by "idx + i", not by "i&qu...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...l; \
> 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]);
You need to index "ptr" by "idx + i", not by "i". Have a look at h...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...rt; 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...