search for: intsxp

Displaying 20 results from an estimated 175 matches for "intsxp".

2007 Apr 04
1
Accessing C++ code from R
...`;' before 'int' main.cpp:51: error: brace-enclosed initializer used to initialize 'R_NativePrimitiveArgType*' Line 51 refers to the standard part to register the function in R: R_CMethodDef cMethods[] = { {"runSimulation", (void* (*) ()) &runSimulation, 27, {INTSXP, INTSXP, INTSXP, REALSXP, REALSXP, REALSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, REALSXP, REALSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, INTSXP, REALSXP, REALSXP, REALSXP}}, {NULL, NULL, 0} }; I had to add the explicit cast of &runSimulation to g...
2013 Jul 24
1
Understanding modification in place
...ted: message("Global") x <- 1:3 .Internal(inspect(x)) x[2] <- 1L .Internal(inspect(x)) message("In function") (function() { x <- 1:3 .Internal(inspect(x)) x[2] <- 1L .Internal(inspect(x)) })() If I run it from the command line, I get: Global @1050bb840 13 INTSXP g0c2 [MARK,NAM(1)] (len=3, tl=0) 1,2,3 @1050bb840 13 INTSXP g0c2 [MARK,NAM(1)] (len=3, tl=0) 1,1,3 In function @1050bb190 13 INTSXP g0c2 [NAM(1)] (len=3, tl=0) 1,2,3 @1050bb190 13 INTSXP g0c2 [NAM(1)] (len=3, tl=0) 1,1,3 i.e. both modifications occur in place. If I put it in a file and source() i...
2018 Apr 29
2
Result of 'seq' doesn't use compact internal representation
> .Internal(inspect(1:10)) @300e4e8 13 INTSXP g0c0 [NAM(3)] 1 : 10 (compact) > .Internal(inspect(seq(1,10))) @3b6e1f8 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,... > system.time(1:1e7) user system elapsed 0 0 0 > system.time(seq(1,1e7)) user system elapsed 0.05 0.00 0.04 It seems that result of fu...
2018 Apr 29
1
Result of 'seq' doesn't use compact internal representation
Thanks -- I'll commit a fix after some testing. Best, luke On 04/29/2018 06:22 AM, Duncan Murdoch wrote: > On 28/04/2018 11:11 PM, Suharto Anggono Suharto Anggono via R-devel wrote: >>> .Internal(inspect(1:10)) >> @300e4e8 13 INTSXP g0c0 [NAM(3)]? 1 : 10 (compact) >>> .Internal(inspect(seq(1,10))) >> @3b6e1f8 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,... >>> system.time(1:1e7) >> ??? user? system elapsed >> ?????? 0?????? 0?????? 0 >>> system.time(seq(1,1e7)) >> ??? user? sys...
2013 Mar 22
1
Why does typeof() modify an object's "named" field?
Hello, Doing typeof() on an object appears to reset the "named" field in its sxpinfo header to 2, which can change the way that subsequent subassignment operations are carried out: X <- 1:5e7 .Internal(inspect(X)) # @4eeb0008 13 INTSXP g0c7 [NAM(1)] (len=50000000, tl=0) 1,2,3,4,5,... system.time(X[1] <- 9L) # user system elapsed # 0 0 0 typeof(X) .Internal(inspect(X)) # @4eeb0008 13 INTSXP g1c7 [MARK,NAM(2)] (len=50000000, tl=0) 9,2,3,4,5,... system.time(X[2] <- 9L) # user system elapsed # 0....
2019 Jul 15
0
Convert STRSXP or INTSXP to factor
...1. Loop through the values to determine the array of levels vector, equivalent to a call to unique(x) at the R level. I don't know if there are any public API functions that will do this for you, a quick grep through the header files suggests there are not. 2. Allocate the ouptut INTSXP and determine the underlying integer value for each factor element. Equivalent to a match(x, levels) in R (x has already been converted to character at this point in the R function). Getting this to be performant would probably be annoying but is doable (e.g., via a hash table or some...
2019 Jul 17
2
ALTREP wrappers and factors
...er vector. Using the wrapper avoided this issue. Here is my initial ALTREP integer vector: > fc0 <- factor(c("a", "a", "b")) > > y <- matter::as.matter(as.integer(fc0)) > y <- matter:::as.altrep(y) > > .Internal(inspect(y)) @7fb0ce78c0f0 13 INTSXP g0c0 [NAM(7)] matter vector (mode=3, len=3, mem=0) Here is what I get without a wrapper: > fc1 <- structure(y, class="factor", levels=levels(x)) > .Internal(inspect(fc1)) @7fb0cae66408 13 INTSXP g0c2 [OBJ,NAM(2),ATT] (len=3, tl=0) 1,1,2 ATTRIB: @7fb0ce771868 02 LISTSXP g0c0 [...
2019 Jul 11
2
Convert STRSXP or INTSXP to factor
Hi, Using the R C PAI, is there a way to convert to convert STRSXP or INTSXP to factor. The idea would be to do in C something similar to the "factor" function (example below): > letters[1:5] # [1] "a" "b" "c" "d" "e" > factor(letters[1:5]) # [1] a b c d e # Levels: a b c d e There is the function setAttr...
2020 Sep 08
4
Operations with long altrep vectors cause segfaults on Windows
...ine$integer.max / 1e9 > [1] 2.147484 >> y <- -1e6:2.2e9 >> .Internal(inspect(y)) > @0x000000000a11a5d8 14 REALSXP g0c0 [REF(65535)] -1000000 : -2094967296 (compact) >> y <- -1e6:2e9 >> .Internal(inspect(y)) > @0x000000000a13adf0 13 INTSXP g0c0 [REF(65535)] -1000000 : 2000000000 (compact) >> > ------------------------- end of transcript ----------------------------------- > So indeed, no seg.fault, R notices that it can't get 15 GB of > memory. > But the bug is bad news: We have *silent*...
2014 May 16
1
SEXPTYPEs
...il, I am now trying to allocate vectors of length larger than 32-bit in C. >From the R internals documentation, I read that: "The sxpinfo header is defined as a 32-bit C structure..." and "A SEXPREC is a C structure containing the 32-bit header..." The question is: does the INTSXP allow vectors larger than 32-bit? A test example: //### int *p_temp; SEXP root = PROTECT(allocVector(VECSXP, 5)); long long int verylargeinteger; // something to compute verylargeinteger, > 32-bit SEXP temp = SET_VECTOR_ELT(root, 0, allocVector(INTSXP, verylargeinteger)); p_temp = INTEGER(...
2019 Jul 18
0
ALTREP wrappers and factors
...wrapper can completely solve your problem. The duplication occurs since your variable y has more than 1 reference number( Please see highlighted), so even you have a wrapper, any changes on the value of the wrapper still can trigger the duplication. > .Internal(inspect(y)) > @7fb0ce78c0f0 13 INTSXP g0c0 *[NAM(7)]* matter vector (mode=3, len=3, > mem=0) My guess is that *matter:::as.altrep* function assigned the variable *y* to a local variable so that it increases the reference number. For example: *This would not cause a duplication* > > a=c(1,2,3) > > .Internal(inspect(a)...
2020 Sep 08
2
[External] Re: Operations with long altrep vectors cause segfaults on Windows
...> >> y <- -1e6:2.2e9 >> >> .Internal(inspect(y)) >> > @0x000000000a11a5d8 14 REALSXP g0c0 [REF(65535)] -1000000 : -2094967296 (compact) >> >> y <- -1e6:2e9 >> >> .Internal(inspect(y)) >> > @0x000000000a13adf0 13 INTSXP g0c0 [REF(65535)] -1000000 : 2000000000 (compact) >> >> >> > ------------------------- end of transcript ----------------------------------- >> >> > So indeed, no seg.fault, R notices that it can't get 15 GB of >> > memory. >> >...
2011 Nov 24
1
Confused about NAMED
Hi, I expected NAMED to be 1 in all these three cases. It is for one of them, but not the other two? > R --vanilla R version 2.14.0 (2011-10-31) Platform: i386-pc-mingw32/i386 (32-bit) > x = 1L > .Internal(inspect(x)) # why NAM(2)? expected NAM(1) @2514aa0 13 INTSXP g0c1 [NAM(2)] (len=1, tl=0) 1 > y = 1:10 > .Internal(inspect(y)) # NAM(1) as expected but why different to x? @272f788 13 INTSXP g0c4 [NAM(1)] (len=10, tl=0) 1,2,3,4,5,... > z = data.frame() > .Internal(inspect(z)) # why NAM(2)? expected NAM(1) @24fc28c 19 VECSXP g0c0 [OBJ,NAM(2),...
2018 Apr 29
0
Result of 'seq' doesn't use compact internal representation
On 28/04/2018 11:11 PM, Suharto Anggono Suharto Anggono via R-devel wrote: >> .Internal(inspect(1:10)) > @300e4e8 13 INTSXP g0c0 [NAM(3)] 1 : 10 (compact) >> .Internal(inspect(seq(1,10))) > @3b6e1f8 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,... >> system.time(1:1e7) > user system elapsed > 0 0 0 >> system.time(seq(1,1e7)) > user system elapsed > 0.05...
2007 Nov 16
4
Returning vectors of two different data types back to R environment (from C).
Hello, Quick question. I have written a C function - I would like to make it return two vectors to the R environment - one STRSXP vector, and one INTSXP vector. Is this possible/ easy to do using the API? I looked, but could not find the answer to this question in the "Writing R Extensions" guide. Thanks very much for your help! Charles [[alternative HTML version deleted]]
2010 Apr 21
2
suggestion how to use memcpy in duplicate.c
>From copyVector in duplicate.c : void copyVector(SEXP s, SEXP t) { int i, ns, nt; nt = LENGTH(t); ns = LENGTH(s); switch (TYPEOF(s)) { ... case INTSXP: for (i = 0; i < ns; i++) INTEGER(s)[i] = INTEGER(t)[i % nt]; break; ... could that be replaced with : case INTSXP: for (i=0; i<ns/nt; i++) memcpy((char *)DATAPTR(s)+i*nt*sizeof(int), (char *)DATAPTR(t), nt*sizeof(int)); break; and similar for the other...
2020 Sep 08
1
[External] Re: Operations with long altrep vectors cause segfaults on Windows
...t; >> y <- -1e6:2.2e9 >> >> .Internal(inspect(y)) >> > @0x000000000a11a5d8 14 REALSXP g0c0 [REF(65535)] -1000000 : -2094967296 (compact) >> >> y <- -1e6:2e9 >> >> .Internal(inspect(y)) >> > @0x000000000a13adf0 13 INTSXP g0c0 [REF(65535)] -1000000 : 2000000000 (compact) >> >> >> > ------------------------- end of transcript ----------------------------------- >> >> > So indeed, no seg.fault, R notices that it can't get 15 GB of >> > memory....
2020 Oct 07
2
Coercion function does not work for the ALTREP object
...be called by R when an assignment operation implicitly introduces coercion for a large ALTREP object. For example, If I create a vector of length 10, the ALTREP coercion function seems to work fine. ``` > x <- 1:10 > y <- wrap_altrep(x) > .Internal(inspect(y)) @0x000000001f9271c0 13 INTSXP g0c0 [REF(2)] I am altrep > y[1] <- 1.0 Duplicating object Coercing object > .Internal(inspect(y)) @0x000000001f927c08 14 REALSXP g0c0 [REF(1)] I am altrep ``` However, if I create a vector of length 1024, R will give me a normal real-type vector ``` > x <- 1:1024 > y <- wrap_...
2014 Apr 02
0
special handling of row.names
...stency in the handling of the compact form of the row.names attributes. When n is the number of rows of a data.frame, the compact form is c(NA_integer_,-n), as in: > d <- data.frame(x=1:10) > .Internal(inspect(d)) @104f174a8 19 VECSXP g0c1 [OBJ,NAM(2),ATT] (len=1, tl=0) @103a7dc60 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,... ATTRIB: @104959380 02 LISTSXP g0c0 [] TAG: @100823078 01 SYMSXP g1c0 [MARK,LCK,gp=0x4000] "names" (has value) @104f17748 16 STRSXP g0c1 [NAM(2)] (len=1, tl=0) @10085c678 09 CHARSXP g1c1 [MARK,gp=0x61] [ASCII] [cached] "x"...
2019 Jun 03
2
Converting non-32-bit integers from python to R to use bit64: reticulate
...hank you Martin for giving to know and developing 'Rmpfr' library for unlimited size integers (GNU C GMP) and arbitrary precision floats (GNU C MPFR): https://cran.r-project.org/package=Rmpfr My question is: In the long term (For R3.7.0 or R3.8.0): Does it have sense that CMP substitutes INTSXP, and MPFR substitutes REALSXP code? With this we would achieve that an integer is always an integer, and a numeric double precision float always a numeric double precision float, without sometimes casting underneath. And would the R Community / R Ordinary Members would be willing to help R Core on...