search for: r_len_t

Displaying 20 results from an estimated 27 matches for "r_len_t".

Did you mean: r_xlen_t
2013 May 14
2
invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ with Rcpp.
...Rcpp. Earlier while using it, I encountered an error as shown below: file74d8254b96d4.cpp: In function ‘Rcpp::NumericVector foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::Function, Rcpp::Function)’: file74d8254b96d4.cpp:10: error: invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ make: *** [file74d8254b96d4.o] Error 1 Below is a mock function that can reproduce this error. I wonder if anyone can tell me what is the problem here. Thank you in advance!! foo<-cppFunction(' NumericVector foo(NumericVector q, NumericVector shape1, NumericVector...
2012 Mar 15
4
replicating C example from the Extensions Manual problem
Dear R People: Here is something that I am sure is very simple. I'm just trying to re-create the C convolution example in the Extensions manual. Here is the subroutine: void convolve(double *a, int *na, double *b, int *nb, double *ab) { R_len_t i, j, nab = *na + *nb - 1; for(i = 0; i < nab; i++) ab[i] = 0.0; for(i = 0; i < *na; i++) for(j = 0; j < *nb; j++) ab[i + j] += a[i] * b[j]; } And here are the results from trying to compile: erin at ubuntu:~$ R CMD SHLIB convolve.c gcc -std=gnu99 -I/usr/share/R/include -fpic -O3 -...
2008 Jan 04
1
Evaluating R expressions from C
I am currently puzzled by a passage in the R Extensions manual, section 5.10: SEXP lapply(SEXP list, SEXP expr, SEXP rho) { R_len_t i, n = length(list); SEXP ans; if(!isNewList(list)) error("`list' must be a list"); if(!isEnvironment(rho)) error("`rho' should be an environment"); PROTECT(ans = allocVector(VECSXP, n)); for(i = 0; i < n; i++) { defin...
2018 Apr 19
2
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...e no solution or fixes in upcoming R version releases. > > The error message is coming from the writetable part of the utils package in the io.c source code(https://svn.r-project.org/R/trunk/src/library/utils/src/io.c): > /* quick integrity check */ > if(XLENGTH(x) != (R_len_t)nr * nc) > error(_("corrupt matrix -- dims not not match length")); > > 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 a...
2018 Apr 19
3
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...>> >>> The error message is coming from the writetable part of the utils >>> package in the io.c source >>> code(https://svn.r-project.org/R/trunk/src/library/utils/src/io.c): >>> /* quick integrity check */ >>> ???????????????? if(XLENGTH(x) != (R_len_t)nr * nc) >>> ???????????????????? error(_("corrupt matrix -- dims not not match >>> length")); >>> >>> 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 c...
2018 Apr 19
0
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...; version releases. >> >> The error message is coming from the writetable part of the utils >> package in the io.c source >> code(https://svn.r-project.org/R/trunk/src/library/utils/src/io.c): >> /* quick integrity check */ >> ???????????????? if(XLENGTH(x) != (R_len_t)nr * nc) >> ???????????????????? error(_("corrupt matrix -- dims not not match >> length")); >> >> 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 >> fai...
2011 Aug 13
1
Latent flaw in SEXPREC definition
There seems to be a latent flaw in the definition of struct SEXPREC in Rinternals.h, which likely doesn't cause problems now, but could if the relative sizes of data types changes. The SEXPREC structure contains a union that includes a primsxp, symsxp, etc, but not a vecsxp. However, in allocVector in memory.c, zero-length vectors are allocated using allocSExpNonCons, which appears to
2018 Apr 19
0
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...;> The error message is coming from the writetable part of the utils >>>> package in the io.c source >>>> code(https://svn.r-project.org/R/trunk/src/library/utils/src/io.c): >>>> /* quick integrity check */ >>>> ???????????????? if(XLENGTH(x) != (R_len_t)nr * nc) >>>> ???????????????????? error(_("corrupt matrix -- dims not not match >>>> length")); >>>> >>>> The issue is that nr*nc is an integer and the size of my matrix, >>>> 2.8 billion elements, exceeds C's limit, so th...
2005 Mar 10
1
R_alloc with more than 2GB (PR#7721)
...ong argument as well? These code excerpts are from R-devel_2005-03-10.tar.gz: char *R_alloc(long nelem, int eltsize) { R_size_t size = nelem * eltsize; SEXP s = allocString(size); ... } SEXP allocString(int length) { return allocVector(CHARSXP, length); } SEXP allocVector(SEXPTYPE type, R_len_t length) { ... case CHARSXP: size = BYTE2VEC(length + 1); ... malloc(sizeof(SEXPREC_ALIGN) + size * sizeof(VECREC))) ... }
2013 Oct 16
1
Parallel R expression evaluations
...owing code snippet for initializing R, parsing and evaluation of R expression // For initialization int res= Rf_initEmbeddedR(R_argc, (char**)R_argv); // For parsing and evaluation SEXP cmd1= Rf_mkChar(rscript); SEXP cmdSexp, cmdexpr, sresult = R_NilValue; ParseStatus status; R_len_t i=0; PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, cmd1); // parsing vector for R expressions cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); // error handling return; } for(i = 0; i < Rf_l...
2004 Nov 12
1
dyn.load problem
...)) : unable to load shared library "C:/Dev-Cpp/teste": LoadLibrary failure: Par??metro incorreto. (Incorrect Parameter) My C code is (extracted form Writing R Extension): #include <R.h> #include <Rinternals.h> SEXP convolve2(SEXP a, SEXP b) { R_len_t i, j, na, nb, nab; double *xa, *xb, *xab; SEXP ab; PROTECT(a = coerceVector(a, REALSXP)); PROTECT(b = coerceVector(b, REALSXP)); na = length(a); nb = length(b); nab = na + nb - 1; PROTECT(ab = allocVector(REALSXP, nab)); xa = REAL(a); xb = REAL(b);...
2006 Mar 27
1
Safe to UNPROTECT() when object is assigned to a list?
...he objects as part of another object (which automatically protects them) or unprotect them immediately after use." BTW, should it say "...another [protected] object..."? Example from "5.7.4 Attributes" illustrating my question: SEXP out(SEXP x, SEXP y) { R_len_t i, j, nx, ny; double tmp; SEXP ans, dim, dimnames; nx = length(x); ny = length(y); PROTECT(ans = allocVector(REALSXP, nx*ny)); for(i = 0; i < nx; i++) { tmp = REAL(x)[i]; for(j = 0; j < ny; j++) REAL(ans)[i + nx*j] = tmp * REAL(...
2004 Nov 07
2
Problem with dyn.load()
...nd MinGW as indicated in http://www.murdoch-sutherland.com/Rtools/ an with correct path). I would like run the coded write below named conv.c (Example from "Write R Extension") : #include <R.h> #include <Rinternals.h> SEXP convolve2(SEXP a, SEXP b) { R_len_t i, j, na, nb, nab; double *xa, *xb, *xab; SEXP ab; PROTECT(a = coerceVector(a, REALSXP)); PROTECT(b = coerceVector(b, REALSXP)); na = length(a); nb = length(b); nab = na + nb - 1; PROTECT(ab = allocVector(REALSXP, nab)); xa = REAL(a); xb = REAL...
2018 Apr 18
1
R Bug: write.table for matrix of more than 2, 147, 483, 648 elements
...ion or fixes in upcoming R version releases. > > The error message is coming from the writetable part of the utils package > in the io.c source code(https://svn.r- > project.org/R/trunk/src/library/utils/src/io.c): > /* quick integrity check */ > if(XLENGTH(x) != (R_len_t)nr * nc) > error(_("corrupt matrix -- dims not not match > length")); > > 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. > > My version: > &...
2005 Nov 07
3
R thread safe
...scale) on a 2-processor AMD server and I would like to know whether R is a tread safe library. The main kernel of the OpenMP parallelization is a C SEXP function that performs the computational routine in parallel with: ******************* SEXP example(SEXP list, SEXP expr, SEXP rho) { R_len_t i, n = length(list); SEXP ans, alocal; omp_lock_t lck; PROTECT(ans = allocVector(VECSXP, n)); ans = allocVector(VECSXP, n); omp_init_lock(&lck); #pragma omp parallel for default(none) private(i, alocal) shared(list, lck,rho, ans, n, expr) for(i = 0; i...
2005 Oct 12
1
Using matprod from array.c
...ne, x, &nrx, y, &nry, &zero, z, &nrx); } else /* zero-extent operations should return zeroes */ for(i = 0; i < nrx*ncy; i++) z[i] = 0; } /* test function: matrix multiplication of nr by nc matrix with nc-vector */ SEXP my_matprod(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_m...
2007 Aug 23
1
.Call and to reclaim the memory by allocVector
...----------- #include "R.h" #include "Rinternals.h" #include "Rdefines.h" SEXP crossprod2(SEXP a, SEXP b); //modified from convolve2 in the R extension //R CMD SHLIB crossprod2.c #include <R.h> #include <Rinternals.h> SEXP crossprod2(SEXP a, SEXP b) { R_len_t i, j, na, nb, nab; double *xa, *xb, *xab; SEXP ab; PROTECT(a = coerceVector(a, REALSXP)); PROTECT(b = coerceVector(b, REALSXP)); na = length(a); nb = length(b); //nab = na + nb - 1; nab=na*nb;// we are doing the cross product PROTECT(ab = allocVecto...
2007 Aug 23
1
.Call and to reclaim the memory by allocVector
...----------- #include "R.h" #include "Rinternals.h" #include "Rdefines.h" SEXP crossprod2(SEXP a, SEXP b); //modified from convolve2 in the R extension //R CMD SHLIB crossprod2.c #include <R.h> #include <Rinternals.h> SEXP crossprod2(SEXP a, SEXP b) { R_len_t i, j, na, nb, nab; double *xa, *xb, *xab; SEXP ab; PROTECT(a = coerceVector(a, REALSXP)); PROTECT(b = coerceVector(b, REALSXP)); na = length(a); nb = length(b); //nab = na + nb - 1; nab=na*nb;// we are doing the cross product PROTECT(ab = allocVecto...
2012 Dec 10
1
Changing arguments inside .Call. Wise to encourage "const" on all arguments?
...tarts modifying it? Here's an example with similar usage in Writing R Extensions, section 5.10.1 "Calling .Call". It protects the arguments a and b (needed ??), then changes them. #include <R.h> #include <Rdefines.h> SEXP convolve2(SEXP a, SEXP b) { R_len_t i, j, na, nb, nab; double *xa, *xb, *xab; SEXP ab; PROTECT(a = AS_NUMERIC(a)); /* PJ wonders, doesn't this alter "a" in calling code*/ PROTECT(b = AS_NUMERIC(b)); na = LENGTH(a); nb = LENGTH(b); nab = na + nb - 1; PROTECT(ab = NE...
2011 Aug 14
0
Improved version of Rprofmem
...oid R_ReportAllocation(R_size_t); +/* Declarations relating to Rprofmem */ + +static int R_IsMemReporting; +static int R_MemReportingToTerminal; +static int R_MemPagesReporting; +static int R_MemDetailsReporting; +static FILE *R_MemReportingOutfile; +static R_size_t R_MemReportingThreshold; +static R_len_t R_MemReportingNElem; +static void R_ReportAllocation (R_size_t, SEXPTYPE, R_len_t); static void R_ReportNewPage(); -#endif extern SEXP framenames; @@ -790,9 +797,7 @@ if (page == NULL) mem_err_malloc((R_size_t) R_PAGE_SIZE); } -#ifdef R_MEMORY_PROFILING - R_ReportNewPage(); -#...