similar to: C-side: Applying a function (given as param) to data (given as param)

Displaying 20 results from an estimated 50000 matches similar to: "C-side: Applying a function (given as param) to data (given as param)"

2011 Jun 03
1
C-Side: Applying a function (given as param) to data (given as param)
Hello, I'm implementing a package (C-extension), where one function gets data and a function that needs to be applied to the data. I want to apply the function to (parts of) the data on the C-side. 1) how do I apply a function (given via SEXP) to data 2) how do I select parts of the data (also provided via SEXP)? Comment on 2: I want to implement a moving/rolling/running apply on the data,
2003 Jan 17
1
Arguments of R- and C-side of internal functions
Dear R experts, I looked at the body of, say, `optim' function and found the call to the `.Internal', C optim function. It looks like this: .Internal(optim(par, fn1, gr1, method, con, lower, upper)) On the other hand, the C prototype of optim is: SEXP do_optim(SEXP call, SEXP op, SEXP args, SEXP rho); So, I guess that all the list of parameters passing in R are assigned to
2006 Dec 24
2
FW: Passing lists from R to C, extracting elements, and sending lists back again
Thank you to everyone who responded to my previous post regarding the integration into R of C programs that use external libraries. I have another issue that I simply have not been able to figure out using documentation, list archives, and so forth. I have data that is stored in R lists. I would like to pass the list to C code using the .Call function, perform mathematical operations on the
2011 Aug 04
1
How to seed the R random number generator in C (standalone) with an instance of .Random.seed
hello all, I use the R standalone math library in my own C program, and the default R random number generator can be seeded with set_seed(const unsigned int, const unsigned int). How could I seed the RNG with an instance of .Random.seed ? I would need this or a similar workaround for debugging purposes. More precisely, I use the default R random number generator to sample from various
2012 Apr 22
1
Sending lists using .C
Hi, I posted around a week ago and I will try this time with a more detailed description. I am converting R code to C code to boost speed as currently it takes a few days to run. Now I will try describe this with as detail as possible. I have a list of size 47. Each element of the list is itself a list of size 7, and each of these lists are arbitrarily long lists of integers. I.e. If my main
2005 Mar 16
1
.Call - applying setAttrib(x, R_DimSymbol, s) to a matrix being an element of a list
Dear R developers, I am writing some C code that loads multiple images into a list of R matrices. The whole R object is created within the C code. To simplify coding, elements of the list are first created as vectors and then converted to corresponding matrices using setAttrib(x, R_DimSymbol, s). Generally the code works fine except for one detail. Applying setAttrib sets ALL elements
2020 Sep 08
0
some questions about R internal SEXP types
On 9/8/20 11:47 AM, Dan Kortschak wrote: > Thanks, Tomas. > > This is unfortunate. Calling between Go and C is not cheap; the gc > implementation of the Go compiler (as opposed to gccgo) uses different > calling conventions from C and there are checks to ensure that Go > allocated memory pointers do not leak into C code. For this reason I > wanted to avoid these if at all
2011 Jul 19
1
Measuring and comparing .C and .Call overhead
Further pursuing my curiosity to measure the efficiency of R/C++ interface, I conducted a simple matrix-vector multiplication test using .C and .Call functions in R. In each case, I measured the execution time in R, as well as inside the C++ function. Subtracting the two, I came up with a measure of overhead associated with each call. I assume that this overhead would be non-existent of the entire
2003 Oct 11
1
evaluating R expressions from C
Hello! I've looked at R help and previous postings, but I am not sure I completely understand the mechanism of evaluating R expressions from C++. They have function SEXP eval(SEXP expr, SEXP rho), but I can't get it to work. Could anyone who used it give any comments on how efficient it is and, if possible, give example of how to use it. My main problem is that I don't really
2014 Jul 07
2
a question about optim.R and optim.c in R
Hi, I am learning R by reading R source code. Here is one question I have about the optim function in R. The context : In the optim.R, after all the prep steps, the main function call call is made via : .External2(C_optim, par, fn1, gr1, method, con, lower, upper). So, it seems to me, to follow what is going on from here, that I should read the optim function in \src\library\stats\src\optim.c
2004 Apr 02
1
Memory Protection & calling C-fun from C
Good morning! The descriptions of memory protection all assume that one is calling a C-function directly from R. I'm not sure if my understanding of calling a C-function from another C-function is correct: Suppose there are two functions SEXP bar(SEXP y) { SEXP b; PROTECT(b = allocVector(...)); ... computations on b UNPROTECT(1); return b } and SEXP foo(SEXP x) { SEXP a;
2011 Jun 09
1
Ctrl-C of functions that allocated mem
Hello, what happens, when a function (R-extension in C), that allocated memory (strdup(), malloc()/calloc() and so on), and is used in interactive mode, then will be stopped via Ctrl-C? I would assume that there remains allocated memory, which is not usable and also not accessable (hence no way to free it). Are there any mechanisms in R that could help in rolling back the allocation? Normally
2010 Jan 02
3
R-devel Digest, Vol 83, Issue 2
[Disclaimer: what is below reflects my understanding from reading the R source, others will correct where deemed necessary] On 1/2/10 12:00 PM, r-devel-request at r-project.org wrote: > > Hello, > > We are currently making lots of changes to Rcpp (see the open Rcpp > mailing list if interested [1] in the details). > > We are now using [2] R_PreserveObject and R_ReleaseObject
2010 Jun 15
1
Error when callin g C-Code
Hi when I call the function below in R, i get the error: Object 'pairlist' can't be converted to 'double'. #include <R.h> #include <Rdefines.h> #include <Rmath.h> SEXP CSimPoisson(SEXP lambda, SEXP tgrid, SEXP T2M, SEXP Ni, SEXP NT) { double sign, EVar; double *xlambda, *xtgrid, *xT2M, *xNi, *xNT, *xtau; SEXP tau; int ltgrid =0; int i = 0; int j = 0;
2005 Oct 31
1
R-functions in C-Code
Dear R users, I would like to use several R functions from a C-code and I have read the "Introduction to the .C Interface to R". Unfortunately, my shared library with the C-code works only in cases where I use R-routines that are defined Rmath.h, eg. ************************************* less test.c: #include <R.h> #include <Rinternals.h> #include <Rmath.h> void
2005 Oct 03
1
storage.mode, C data types and speed
Hi, I am trying to speed up part of an algorithm in which certain columns of a large matrix (X) are replaced by the element-wise product of a matrix (M) and a vector (v). In R, the code might be X[, ind] <- M * v I have written a small C routine to do this for me, but the timing depends on how I define the storage.mode of the objects in R and the data types in C, in a way which I don't
2001 Apr 09
1
syntax error in datetime.c (PR#901)
Full_Name: Naoki Takebayashi Version: 1.2.2 OS: Linux, RedHat 7.0/alpha Submission from: (NULL) (152.3.12.123) With RedHat 7.0/alpha (gcc 2.96-69), I encountered following error: gcc -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -mieee -O2 -mieee -c datetime.c -o datetime.o datetime.c: In function `do_systime': datetime.c:306: parse error before `ans'
2019 Nov 01
0
[External] R C api for 'inherits' S3 and S4 objects
On Fri, 1 Nov 2019, Jan Gorecki wrote: > Dear R developers, > > Motivated by discussion about checking inheritance of S3 and S4 > objects (in head matrix/array topic) I would light to shed some light > on a minor gap about that matter in R C API. > Currently we are able to check inheritance for S3 class objects from C > in a robust way (no allocation, thread safe). This is
2020 Jun 30
0
Build a R call at C level
It is quite known that R documentation on R C api could be improved... Still R-package-devel mailing list should be preferred for this kind of questions. Not sure if that is the best way, but works. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP r_true =
2020 Jun 30
0
Build a R call at C level
Thanks Jan and Tomas for the feedback. Answer from Jan is what I am looking for. Maybe I am not looking in the right place buy it is not easy to understand how these LCONS, CONS, SETCDR...etc works. Thank you Best regards Morgan On Tue, 30 Jun 2020, 12:36 Tomas Kalibera, <tomas.kalibera at gmail.com> wrote: > On 6/30/20 1:06 PM, Jan Gorecki wrote: > > It is quite known that R