search for: allocmatrix

Displaying 20 results from an estimated 45 matches for "allocmatrix".

2012 Jul 31
1
ways of getting around allocMatrix limit?
I need to multiply to very large, nonsparse matrices, and so get the error "allocMatrix: too many elements specified". Is there a way to set the limit for allocMatrix? In my case, the two matrices, A and B, are nxm and mxp where m is small, so I could subdivide each into blocks of submatrices A=rbind(A1,A2,...) and B=cbind(B1,B2,...) then multiply each pair of submatrices, but...
2010 Jul 21
1
Question about allocMatrix error message
Dear R family, I faced a technical problem in r coding. #s=t(dev)%*%dev/(nr-1) # dev (100,000 by 2) stands for deviation from the mean #sinv=solve(s) #t2=diag(dev%*%sinv%*%t(dev)) I got an error message at t2 statement: Error in diag(dev %*% si %*% t(dev)) : allocMatrix: too many elements specified Please let me know if there is a way to overcome this problem. best moohwan
2011 Nov 01
1
reducing a too-large matrix obtained with allocMatrix()
Hello, I have some C code (for a shared lib called via .External) that uses PROTECT(w= allocMatrix(REALSXP, m, n)); mostly successfully. In rare cases, though, the row count m will be an overestimate. Is there a way to reallocate the matrix in-place, something like reAllocMatrix (w,m-excess,n) /* where excess is > 0 */ to chop off the last excess rows of w? I only find out about the...
2009 Feb 17
1
allocMatrix error
...gt; >>>>>>> "VK" == Vadim Kutsyy <vadim@kutsyy.com> >>>>>>> on Fri, 01 Aug 2008 07:35:01 -0700 writes: >> >> VK> Martin Maechler wrote: >> >> >> VK> The problem is in array.c, where allocMatrix check for >> VK> "if ((double)nrow * (double)ncol > INT_MAX)". But why >> VK> itn is used and not long int for indexing? (max int is >> VK> 2147483647, max long int is 9223372036854775807) >> >> >> >> Well, Br...
2012 Dec 06
0
Package party Error in model.matrix.default(as.formula(f), data = blocks) :allocMatrix: too many elements specified
...., data = lu, control = cforest_unbiased(mtry = 2, ntree = 50)) > lu.cf <- cforest(Target ~ ., data = lu, control = cforest_unbiased(mtry = 2, ntree = 100)) > cvi_lu = varimp(lu.cf,threshold = 0.2,conditional= TRUE,OOB=TRUE) Error in model.matrix.default(as.formula(f), data = blocks) : allocMatrix: too many elements specified Anybody please given suggestion? Thanks a lot! [[alternative HTML version deleted]]
2004 Feb 11
1
.Call setAttrib(ans,R_DimSymbol,dim); Crashes.
Hi! I want to return a matrix. The code does the R interfacing. This version does it fine. SEXP ans,dim; PROTECT(ans = NEW_NUMERIC(count*2)); memcpy(NUMERIC_POINTER(ans),result,count*sizeof(double)); memcpy(&(NUMERIC_POINTER(ans)[count]),occur,count*sizeof(double)); /** PROTECT(dim=NEW_INTEGER(2)); INTEGER_POINTER(dim)[0]=2; INTEGER_POINTER(dim)[1]=count;
2007 Jul 10
1
How to preserve data across function calls in a library package
...; Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-exts.html PROTECT(distance=allocMatrix(REALSXP,nrow,k)); ANNpointArray datapoints; ANNpoint qpoint; ANNkd_tree* kdTree; book=Calloc(1,ANN*);...
2007 Jul 10
1
How to preserve data across function calls in a library package
...; Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-exts.html PROTECT(distance=allocMatrix(REALSXP,nrow,k)); ANNpointArray datapoints; ANNpoint qpoint; ANNkd_tree* kdTree; book=Calloc(1,ANN*);...
2004 Jun 16
1
off topic: C/C++ codes for pseudo inverse
Hi, I am looking for C/C++ codes for computing generalized inverse of a matrix. Can anyone help me in this regard? Thanks, Mahbub.
2019 Jun 14
2
R C API resize matrix
Hi, Is there a way to resize a matrix defined as follows: SEXP a = PROTECT(allocMatrix(INTSXP, 10, 2)); int *pa = INTEGER(a) To row = 5 and col = 1 or do I have to allocate a second matrix "b" with pointer *pb and do a "for" loop to transfer the value of a to b? Thank you Best regards Morgan [[alternative HTML version deleted]]
2012 Dec 15
3
interfacing with .Call
...=REAL(W); dimxy=getDim(xymod); PROTECT(xymod=coerceVector(xymod, INTSXP)); xyptr=INTEGER(xymod); dimif=getDim(modif); PROTECT(modif=coerceVector(modif, REALSXP)); ifptr=REAL(modif); //* create SEXP to hold the answer *// SEXP ans; double *ansptr; PROTECT(ans=allocMatrix(REALSXP, dimG[1], dimG[0])); ansptr=REAL(ans); //* calculate the result *// Projector(lptr, dimL, gptr, dimG, wptr, dimW, xyptr, dimxy, ifptr, dimif, ansptr); //* wrap up and return the result to R *// UNPROTECT(6); return(ans); } The function "Projector" works...
2006 Aug 03
1
question about dll crashing R
..." , *transb = "N" ; double one = 1.0 , zero = 0.0 ; xdims = getAttrib (x , R_DimSymbol ) ; ydims = getAttrib (y , R_DimSymbol ) ; mode = REALSXP; nrx = INTEGER( xdims ) [ 0 ] ; ncx = INTEGER( xdims ) [ 1 ] ; nry = INTEGER( ydims ) [ 0 ] ; ncy = INTEGER( ydims ) [ 1 ] ; PROTECT( ans = allocMatrix (mode, nrx , ncy ) ) ; F77_CALL(dgemm) ( transa , transb , &nrx , &ncy , &ncx , &one , REAL( x ) , &nrx , REAL( y ) , &nry , &zero , REAL( ans ) , &nrx ) ; UNPROTECT( 1 ) ; return( ans ) ; } I am also generating random multiavriate normals using the (not pretty) cod...
2011 Mar 29
7
Error en cor, too many elements specified
Hola, tengo una serie de datos datExpr, al usar cor() : cor(datExpr ,method = "pearson", use ="pairwise.complete.obs") me da el siguiente error allocMatrix: too many elements specified Trate con "complete.obs", "na.or.complete", y el resto de las opciones para "use", pero siempre me da algun error.  ¿Alguna idea de como puedo hacer que cor() lea todo mis datos? Gracias Estefanía [[alternative HTML version deleted]]
2014 Dec 18
2
segfault when trying to allocate a large vector
...to the same outcome. In my package, I would use large vectors that cannot be assumed to be sparse - so utilities for sparse matrices may not be considered. I run R on ubuntu 64-bit, with 8G RAM, and a 64-bit R build (3.1.2). As my problem looks close to that seen in http://r.789695.n4.nabble.com/allocMatrix-limits-td864864.html, following what I have seen in ?"Memory-limits" I checked that ulimit -v returns "unlimited". I guess I must miss something, like contiguity issues, or other. Does anyone have a clue for me? Thanks by advance, Pierrick
2013 Aug 27
1
Error in simulation. NAN
...= (double *) R_alloc(J, sizeof(double)); F77_NAME(dcopy)(&incJ, start_mu_P, &incOne, mu_app_P, &incOne); /***************************************** // OUTPUT di R *****************************************/ SEXP mu_out_r,alpha_out_r; PROTECT(mu_out_r = allocMatrix(REALSXP, J, nSamples_save)); nProtect++; double *mu_out_P = REAL(mu_out_r); PROTECT(alpha_out_r = allocMatrix(REALSXP, 1, nSamples_save)); nProtect++; double *alpha_out_P = REAL(alpha_out_r); // // PROTECT(accept_r = allocMatrix(REALSXP, 1, 1)); nProtect++; /******...
2015 Feb 05
2
Invalid read of size 8
...{ Rprintf("%f ", MatCovInv[k][i*nLC+j]); } Rprintf("\n"); } Rprintf("\n\n"); } After that i define an R variable int nProtect =0; SEXP zDP_out_r; PROTECT(zDP_out_r = allocMatrix(INTSXP, nT, nSamples_save)); nProtect++; int *zDP_out_P = INTEGER(zDP_out_r); and using the same syntax as before for(k=0;k<K+1;k++) { Rprintf("Later Cov Extra %i \n",k); for(i=0;i<nLC;i++) { for(j=i;j<nLC;j+...
2002 Dec 18
2
meta analysis
Dear R-lister, is there any function for Meta Analysis in R? (like homogeneity an, risk differences, relative riskm amd odds ratios? Many thanks, Edwin
2006 Mar 09
0
When calling external C-function repeatedly I get different results; can't figure out why..
..., SEXP y) { int nrx, ncx, nry, ncy, mode, i; SEXP xdims, ydims, ans, ans2, tr; xdims = getAttrib(x, R_DimSymbol); ydims = getAttrib(y, R_DimSymbol); mode = REALSXP; nrx = INTEGER(xdims)[0]; ncx = INTEGER(xdims)[1]; nry = INTEGER(ydims)[0]; ncy = INTEGER(ydims)[1]; PROTECT(ans = allocMatrix(mode, nrx, ncy)); PROTECT(ans2 = allocMatrix(mode, nrx, ncy)); PROTECT(tr = allocVector(mode, 1)); matprod(REAL(x), nrx, ncx, REAL(y), nry, ncy, REAL(ans)); matprod(REAL(ans), nrx, ncy, REAL(ans), nrx, ncy, REAL(ans2)); for (i=0; i< nrx; i++){ REAL(tr)[0] = REAL(tr)[0] +...
2005 Apr 16
1
SET_LENGTH
Hello. I'm trying to read a delimited file. I'm a little new to the R api. In the program, I do something like this... /*****************************/ SEXP retval; PROTECT(retval = allocMatrix(STRSXP,1,names.dim)); int r_eltctr = 0; while(!myfile.eof()) { SET_LENGTH(retval,r_eltctr+num_of_fields); for(int i = 0;numofcolumns; ++i) { INTEGER(retval)[r_eltctr++] = 1;/*some value...*/ } ++r_eltctr; } UNPROTECT(1); /***************************************/ There is a segm...
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",