search for: r_xlen_t

Displaying 20 results from an estimated 58 matches for "r_xlen_t".

2015 Sep 20
2
Long vectors: Missing values and R_xlen_t?
Is there a missing value constant defined for R_xlen_t, cf. NA_INTEGER (== R_NaInt == INT_MIN) for int(eger)? If not, is it correct to assume that missing values should be taken care/tested for before coercing from int or double? Thank you, Henrik
2015 Sep 21
0
Long vectors: Missing values and R_xlen_t?
On Sep 20, 2015, at 3:06 PM, Henrik Bengtsson <henrik.bengtsson at ucsf.edu> wrote: > Is there a missing value constant defined for R_xlen_t, cf. NA_INTEGER > (== R_NaInt == INT_MIN) for int(eger)? If not, is it correct to > assume that missing values should be taken care/tested for before > coercing from int or double? > R_xlen_t is type of the vector length (see XLENGTH()) and as such never holds a missing value (since...
2013 Jul 12
1
robustbase compilation problem: probably boneheaded? maybe 32-bit?
...from the names of the targets it doesn't look like it is tested on 32-bit platforms? The error is: gcc -std=gnu99 -I/usr/local/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c init.c -o init.o In file included from init.c:3: robustbase.h:20: error: redefinition of typedef ?R_xlen_t? /usr/local/lib/R/include/Rinternals.h:69: note: previous declaration of ?R_xlen_t? was here As far as I can see there isn't any junk left over in my systems from previous installs. Rinternals.h has #ifdef LONG_VECTOR_SUPPORT typedef ptrdiff_t R_xlen_t; typedef struct { R_xlen_t lv...
2017 Aug 27
0
R_xlen_t is an integer type
...el NEWS item: approx(), spline(), splinefun() and approxfun() also work for long vectors. In current R devel, in function 'approx1' in src/library/stats/src/approx.c and in function 'spline_eval' in src/library/stats/splines.c, in #ifdef LONG_VECTOR_SUPPORT there is a comment "R_xlen_t is double". It is incorrect. In Rinternals.h, in #ifdef LONG_VECTOR_SUPPORT R_xlen_t is defined as ptrdiff_t , an integer type. In function 'approx1' in src/library/stats/src/approx.c, R_xlen_t ij = (i+j) / 2; can be used unconditionally. In function 'spline_eval' in src/lib...
2019 Oct 23
2
Unexpected behavior when using macro to loop over vector
...t;R_ext/Itermacros.h" #define GET_REGION_BUFSIZE 2 //Redefine the macro since C++ is not happy with the implicit type conversion #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \ strt, nfull, expr) do { \ const etype *px = (etype*)DATAPTR_OR_NULL(sx); \ if (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_...
2023 Feb 11
1
scan(..., skip=1e11): infinite loop; cannot interrupt
...copy) @@ -835,7 +835,7 @@ attribute_hidden SEXP do_scan(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP ans, file, sep, what, stripwhite, dec, quotes, comstr; - int c, flush, fill, blskip, multiline, escapes, skipNul; + int c = 0, flush, fill, blskip, multiline, escapes, skipNul; R_xlen_t nmax, nlines, nskip; const char *p, *encoding; RCNTXT cntxt; @@ -952,7 +952,7 @@ if(!data.con->canread) error(_("cannot read from this connection")); } - for (R_xlen_t i = 0; i < nskip; i++) /* MBCS-safe */ + for (R_xlen_t i = 0; i < nskip && c != R_E...
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...quot;double") > system.time(sum(z, na.rm=FALSE)) user system elapsed 4.49 0.00 4.51 Following the source code, I'm pretty sure the code (https://github.com/wch/r-source/blob/trunk/src/main/summary.c#L112-L128) performing the calculation is: static Rboolean rsum(double *x, R_xlen_t n, double *value, Rboolean narm) { LDOUBLE s = 0.0; Rboolean updated = FALSE; for (R_xlen_t i = 0; i < n; i++) { if (!narm || !ISNAN(x[i])) { if(!updated) updated = TRUE; s += x[i]; } } if(s > DBL_MAX) *value = R_PosInf; else if (s < -DBL_MAX) *value = R_N...
2019 Oct 25
2
Unexpected behavior when using macro to loop over vector
...//Redefine the macro since C++ is not happy with the implicit type >> conversion >> #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \ >> ? strt, nfull, expr) do { \ >> const etype *px = (etype*)DATAPTR_OR_NULL(sx); \ >> if (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); \ >&...
2023 Mar 13
0
scan(..., skip=1e11): infinite loop; cannot interrupt
...??R_CheckUserInterrupt(); ?????j?=?10000; ?} . In?current?R?devel?(r83976),?if?EOF?is?reached,?the?outer?loop?keeps?going,?i?keeps?incrementing?until?nskip. The?outer?loop?could?be?made?to?also?stop?on?EOF. Alternatively,?not?using?nested?loop?is?possible,?like?the?following. ?if?(nskip)?for?(R_xlen_t?i?=?0,?j?=?10000;?;?)?{?/*?MBCS-safe?*/ ?c?=?scanchar(FALSE,?&data); ?if?(!j--)?{ ?????R_CheckUserInterrupt(); ?????j?=?10000; ?} ?if?((c?==?'\n'?&&?++i?==?nskip)?||?c?==?R_EOF) ?????break; ?} ----------- On?2/11/23?09:33,?Ivan?Krylov?wrote: >?On?Fri,?10?Feb?2023?23:38:55?-...
2018 Apr 19
3
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...; The issue is that nr*nc is an integer and the size of my matrix, 2.8 >>> billion elements, exceeds C's limit, so the check forces the code to >>> fail. >> >> Yes, looks like a typo:? R_len_t is an int, and that's how nr was >> declared.? It should be R_xlen_t, which is bigger on machines that >> support big vectors. >> >> I haven't tested the change; there may be something else in that >> function that assumes short vectors. > Indeed, I think the function won't work for long vectors because of > EncodeElement2 an...
2013 Apr 09
2
Behaviors of diag() with character vector in R 3.0.0
Dear all, According to CHANGES IN R 3.0.0: o diag() as used to generate a diagonal matrix has been re-written in C for speed and less memory usage. It now forces the result to be numeric in the case diag(x) since it is said to have 'zero off-diagonal entries'. diag(x) does not work for character vector in R 3.0.0 any more. For example, v <- c("a",
2019 Sep 23
2
What is the best way to loop over an ALTREP vector?
...ermacros.h #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \ strt, nfull, expr) do { \ * const** etype *px = DATAPTR_OR_NULL(sx); * \ if (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 \ }...
2023 Feb 11
1
scan(..., skip=1e11): infinite loop; cannot interrupt
Hello, All: I have a 4.54 GB file that I'm trying to read in chunks using "scan(..., skip=__)". It works as expected for small values of "skip" but goes into an infinite loop for "skip=1e11" and similar large values of skip: I cannot even interrupt it; I must kill R. Below please find sessionInfo() with a toy example. My real problem is a large
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...ouble, I can reproduce the penalty of having NA_real_ with na.rm=FALSE; > sum3 <- inline::cfunction(sig=c(x="double", narm="logical"), body=' #define LDOUBLE long double double *x_ = REAL(x); int narm_ = asLogical(narm); int n = length(x); LDOUBLE sum = 0.0; for (R_xlen_t i = 0; i < n; i++) { if (!narm_ || !ISNAN(x_[i])) sum += x_[i]; } return ScalarReal((double)sum); ') > x <- rep(0, 1e8) > stopifnot(typeof(x) == "double") > system.time(sum3(x, narm=FALSE)) user system elapsed 0.40 0.00 0.44 > y <- rep(NA_real_,...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...T_REGION_BUFSIZE 2 > //Redefine the macro since C++ is not happy with the implicit type > conversion > #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \ > strt, nfull, expr) do { \ > const etype *px = (etype*)DATAPTR_OR_NULL(sx); \ > if (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) > // [[R...
2019 Sep 24
2
What is the best way to loop over an ALTREP vector?
...e, vtype, \ > > > > strt, nfull, expr) do { \ > > > > * const** etype *px = DATAPTR_OR_NULL(sx); * > \ > > > > if (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...
2017 Jan 11
2
accelerating matrix multiply
...er system elapsed > 2710.154 20.999 58.398 > > The NaN checking code is not being vectorized because of the early > exit when NaN is detected: > > /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 > * The test is only O(n) here. > */ > for (R_xlen_t i = 0; i < NRX*ncx; i++) > if (ISNAN(x[i])) {have_na = TRUE; break;} > if (!have_na) > for (R_xlen_t i = 0; i < NRY*ncy; i++) > if (ISNAN(y[i])) {have_na = TRUE; break;} > > I tried deleting the 'break'. By inspecting the asm code, I verified > that...
2017 Jan 16
1
accelerating matrix multiply
...obreak" version, but the performance of it was the same as "break". For my experiments I extracted NaN checks into a function. This was the "break" version (same performance as the current code): static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) { for (R_xlen_t i = 0; i < n; i++) if (ISNAN(x[i])) return TRUE; return FALSE; } And this was the "nobreak" version: static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) { Rboolean has = FALSE; for (R_xlen_t i = 0; i < n; i++) if (ISNAN(x[i])) has=TRUE; return...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...is not happy with the implicit type > >> conversion > >> #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \ > >> strt, nfull, expr) do { \ > >> const etype *px = (etype*)DATAPTR_OR_NULL(sx); \ > >> if (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, \ > &...
2019 Sep 24
0
What is the best way to loop over an ALTREP vector?
..._PARTIAL(sx, px, idx, nb, etype, vtype, \ > > strt, nfull, expr) do { \ > > * const** etype *px = DATAPTR_OR_NULL(sx); * \ > > if (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 \ > &gt...