Displaying 20 results from an estimated 2000 matches similar to: "Accessing C++ code from R"
2012 Feb 06
1
Segfault on ".C" registration via R_CMethodDef according to 'Writing R Extensions'.
Dear R List,
I encountered a serious problem regarding the registration of ".C" when following the documentation "Writing R Extensions"
that leads to a segmentation fault (tested on windows and mac os x).
The registration mechanism for ".C" routines via R_registerRoutines and
the R_CMethodDef structure has been enhanced recently with the
addition of two fields, one
2012 Dec 15
3
interfacing with .Call
Hi
My code is as following:
#include <R.h>
#include <Rinternals.h>
//* the Projector part *//
void Projector(double *L, int *dimL, double *G, int *dimG, double *W, int
*dimW, int *xymod, int *dimxy, double *modif, int *dimif, double *Lsum)
{ ...}
//* the interface part *//
#define getDim(A) INTEGER(coerceVector(getAttrib(A,R_DimSymbol), INTSXP))
SEXP Projector5(SEXP L, SEXP G,
2020 Sep 08
4
Operations with long altrep vectors cause segfaults on Windows
>>>>> Martin Maechler
>>>>> on Tue, 8 Sep 2020 10:40:24 +0200 writes:
>>>>> Hugh Parsonage
>>>>> on Tue, 8 Sep 2020 18:08:11 +1000 writes:
>> I can only reproduce on Windows, but reliably (both 4.0.0 and 4.0.2):
>> $> R --vanilla
>> x <- c(0L, -2e9:2e9)
>> # > Segmentation
2020 Oct 07
2
Coercion function does not work for the ALTREP object
Hi all,
The coercion function defined for the ALTREP object will not 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
2020 Sep 08
1
[External] Re: Operations with long altrep vectors cause segfaults on Windows
>>>>> luke-tierney
>>>>> on Tue, 8 Sep 2020 09:42:43 -0500 (CDT) writes:
> On Tue, 8 Sep 2020, Martin Maechler wrote:
>>>>>>> Martin Maechler
>>>>>>> on Tue, 8 Sep 2020 10:40:24 +0200 writes:
>>
>>>>>>> Hugh Parsonage
>>>>>>> on Tue, 8 Sep 2020
2020 Sep 08
2
[External] Re: Operations with long altrep vectors cause segfaults on Windows
On Tue, 8 Sep 2020, Hugh Parsonage wrote:
> Thanks Martin. On further testing, it seems that the segmentation
> fault can only occur when the amount of obtainable memory is
> sufficiently high. On my machine (admittedly with other processes
> running):
>
> $ R --vanilla --max-mem-size=30G -e "x <- c(0L, -2e9:2e9)"
> Segmentation fault
>
> $ R --vanilla
2003 Dec 09
1
R Interface handholding
Hello,
I need a bit of handholding with R, specifically, with writing
packages for it. I'm a systems programmer, and am, on the request
of several users of our software, working on generating R interfaces.
For starters, I've written the following R function (which compiles):
SEXP myincr(SEXP Rinput)
{ // Returns input integer incremented by one
int input;
SEXP returner;
PROTECT(Rinput =
2013 Jan 24
1
Copy on assignment and .Internal(inspect())
Hi,
I would like to know if it's ok to use .Internal(inspect(x)) in order
to detect vector copying.
Take for example the following silly code:
f <- function() {
x = seq(10)
print(.Internal(inspect(x)))
for(i in seq(10)) {
x[i] <- x[i] + 1
print(.Internal(inspect(x)))
}
}
The output of f() was:
@bd7acf0 13 INTSXP g0c4 [NAM(1)] (len=10, tl=0) 1,2,3,4,5,...
[1] 1 2
2013 Apr 17
1
stack imbalance in max.col for non-real matrices
It's tough to reliably reproduce, but I often get stack imbalance warnings
when calling max.col() on non-real/double matrix. The code is conditionally
PROTECTing but not incrementing its nprot counter for the eventual
UNPROTECT. Pretty sure this would fix (but I haven't tested it):
Index: array.c
===================================================================
--- array.c (revision
2003 Dec 16
1
Memory issues in "aggregate" (PR#5829)
Full_Name: Ed Borasky
Version: 1.8.1
OS: Windows XP Professional
Submission from: (NULL) (208.252.96.195)
R 1.8.1 seems to be running into a memory allocation problem in the "aggregate"
function. I have a rather large dataset (14 columns by 223,000 rows -- almost 40
megabytes) and a script that performs some processing on it. The system is a 768
MB Pentium 4. Here's the console
2020 Oct 08
1
Coercion function does not work for the ALTREP object
Hi Gabriel, here is a simple package for reproducing the problem.
https://github.com/Jiefei-Wang/testPkg
Best,
Jiefei
On Thu, Oct 8, 2020 at 5:04 AM Gabriel Becker <gabembecker at gmail.com> wrote:
> Jiefei,
>
> Where does the code for your altrep class live?
>
> Thanks,
> ~G
>
> On Wed, Oct 7, 2020 at 4:25 AM Jiefei Wang <szwjf08 at gmail.com> wrote:
>
2019 Jun 03
2
Converting non-32-bit integers from python to R to use bit64: reticulate
Thank 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
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
2002 Oct 14
1
R 1.6.0 Solaris crash with xmalloc: out of virtual memory
[some de-capitalization of *SXP done manually by mailing
list maintainer ; the originally was caught as potential spam. MM]
I have a little R program that crashes with the message
xmalloc: out of virtual memory
The code has a repeat{} loop that watches the sizes of some files.
When there's an increase it updates things by reading the last 65
lines of each file, doing some
2013 Jul 13
2
missing PROTECT() in src/main/arithmetic.c
at lines 651 & 653 (integer_binary function):
if (code == DIVOP || code == POWOP)
ans = allocVector(REALSXP, n);
else
ans = allocVector(INTSXP, n);
There are calls to warningcall() later in the function, which can
trigger garbbage collection.
Looks like the typical scenario where it seemed pretty safe to not
PROTECT in the original version of the function but
2019 Jul 17
2
ALTREP wrappers and factors
Hello,
I?m experimenting with ALTREP and was wondering if there is a preferred way to create an ALTREP wrapper vector without using .Internal(wrap_meta(?)), which R CMD check doesn?t like since it uses an .Internal() function.
I was trying to create a factor that used an ALTREP integer, but attempting to set the class and levels attributes always ended up duplicating and materializing the
2019 May 16
3
ALTREP: Bug reports
Hello Luke and Gabriel,
Thank you very much for your quick responses. The explanation of STDVEC is
very helpful and I appreciate it! For the wrapper, I have a few new
questions.
1. Like Luke said a mutable object is not possible. However, I noticed that
there is one extra argument *deep* in the function duplicate. I've googled
all the available documentation for ALTREP but I did not find
2019 May 16
3
ALTREP: Bug reports
Hello,
I have encountered two bugs when using ALTREP APIs.
1. STDVEC_DATAPTR
>From RInternal.h file it has a comment:
/* ALTREP support */
> void *(STDVEC_DATAPTR)(SEXP x);
However, this comment might not be true, the easiest way to verify it is to
define a C++ function:
void C_testFunc(SEXP a)
> {
> STDVEC_DATAPTR(a);
> }
and call it in R via
> a=1:10
> >
2019 Jan 22
2
Objectsize function visiting every element for alt-rep strings
On Mon, 21 Jan 2019, Martin Maechler wrote:
>>>>>> Travers Ching
>>>>>> on Tue, 15 Jan 2019 12:50:45 -0800 writes:
>
> > I have a toy alt-rep string package that generates
> > randomly seeded strings. example: library(altstringisode)
> > x <- altrandomStrings(1e8) head(x) [1]
> >
2013 Dec 16
1
External pointers and changing SEXPTYPE
Dear Developers,
I've been struggling through writing R extension in C. I've been using
an external pointer to store my data (please see sample below). I
encountered a very weird erroneous behaviour: when I tried to use my
external pointer to a structure holding several types of data,
including SEXPs, I discovered that SEXPs change their types between
returning from initialization