search for: truelength

Displaying 9 results from an estimated 9 matches for "truelength".

2005 Sep 04
1
A memory management question
Can someone explain the use of SETLENGTH() and SETTRUELENGTH()? I would like to allocate a vector and reserve some space at the end, so that it appears shorter than the allocated size. So that I can more efficiently append to the vector, without requiring a new copy every time. So I'd like to use SETLENGTH() with a shorter apparent length, and bump thi...
2013 Oct 12
1
[PATCH] minor suggestions for R-ints manual
...runk/doc/manual/R-ints.texi =================================================================== --- trunk/doc/manual/R-ints.texi (revision 64048) +++ trunk/doc/manual/R-ints.texi (working copy) @@ -462,7 +462,7 @@ (which are 32 bits on all @R{} platforms). @item REALSXP - at code{length}, @code{truelength} followed by a block of C @code{double}s + at code{length}, @code{truelength} followed by a block of C @code{double}s. @item CPLXSXP @code{length}, @code{truelength} followed by a block of C99 @code{double @@ -1330,7 +1330,7 @@ The relationship between the pairs is similar: @code{warning} trie...
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]]
2007 Mar 09
4
How to create a list that grows automatically
Dear R users I would like to know if there is a way to create a list or an array (or anything) which grows automatically as more elements are put into it. What I want to find is something equivalent to an ArrayList object of Java language. In Java, I can do the following thing: // Java code ArrayList myArray = new ArrayList(); myArray.add("object1"); myArray.add("object2");
2007 Mar 09
4
How to create a list that grows automatically
Dear R users I would like to know if there is a way to create a list or an array (or anything) which grows automatically as more elements are put into it. What I want to find is something equivalent to an ArrayList object of Java language. In Java, I can do the following thing: // Java code ArrayList myArray = new ArrayList(); myArray.add("object1"); myArray.add("object2");
2019 Jun 17
0
R C API resize matrix
Matrix is just a vector with the dim attribute. Assuming it is not referenced by anyone, you can set any values to the dim attribute. As for the vector, you can use SET_LENGTH() to shorten it - but I'm not sure how official it is - it was originally designed to work, but there were abuses of TRUELENGTH so not sure where we stand now (shortened vectors used to fool the garbage collector as far as object sizes go). I wouldn't do it unless you're dealing with rally huge matrices. Cheers, Simon > On Jun 14, 2019, at 5:31 PM, Morgan Morgan <morgan.emailbox at gmail.com> wrote: >...
2017 Nov 21
1
Truncating vectors by reference in C-backend
Dear all, I want to create a function shrinkVector(x) that takes x and truncates it to the first element without copy. With SETLENGTH and SET_TRUELENGTH, I can achieve that. You can find a reproducible example below. But the memory that was freed is not available for other objects afterwards, except if x is a list (VECSXP). Any suggestions? library(inline) ## define the shrinking function shrinkVector <- cfunction(signature(x = "ANY&quo...
2011 Jan 17
1
isoreg memory leak?
I believe there is a memory leak in isoreg in the current version of R, as I believe the following shows > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 120405 3.3 350000 9.4 350000 9.4 Vcells 78639 0.6 786432 6.0 392463 3.0 > for(k in 1:100) { + + y <- runif(10000) + isoreg(x,y) + } > rm(x) > rm(y) > gc() used (Mb) gc
2007 Oct 18
3
append/concatenate an element to a list in C-language
dear people, i need to code a function in C working in R and receives two R SEXP objects as parameters, where one is a list and another is a vector of integers: void f(SEXP list, SEXP vector) { ... return list; } and it should return the given list with the integer vector concatenated at the end (as the last element of the list). the list can be really big so i would not like to create a