similar to: Inline Package: void vs return type functions

Displaying 20 results from an estimated 2000 matches similar to: "Inline Package: void vs return type functions"

2010 Apr 08
2
I can´t run the example shown in the inline package
I want to run some R script using the inline package (which allows to create and run inline C++ code in my humble understanding). So, after loading the required packages and copy and paste the example that runs C code (in the Reference Manual as a PDF), I have a compilation error. Any body has ever tried this inline package? -- View this message in context:
2013 Feb 01
1
Problem using raw vectors with inline cfunction
Hello, >From what I understood from the documentation I found, when using the inline cfunction with convention=".C", R raw vectors should be given as unsigned char* to the C function. But consider the following script: library(inline) testRaw <- cfunction(signature(raw='raw', len='integer') , body=' int l = *len; int i = 0;
2010 Mar 25
1
Error using Rcpp
Hi, Im not sure if this is the right place to post this. I am using Xubuntu Karmic Koala and am trying to use the Rcpp package. I am testing it using a simple code that takes in a vector and adds 1 to each element: #include <Rcpp.h> // This file takes in a vector and adds one to each entry RcppExport SEXP addone(SEXP vec){ // create a local copy of vec Rcpp::NumericVector
2010 Jun 18
3
C interface
Greetings, I am trying to call simple C-code from R. I am on Windows XP with RTools installed. The C-function is #include <R.h> #include <Rinternals.h> #include <Rmath.h> #include <Rdefines.h> // prevent name mangling extern "C" { SEXP __cdecl test(SEXP s){ SEXP result; PROTECT(result = NEW_NUMERIC(1)); double* ptr=NUMERIC_POINTER(result); double t =
2006 Dec 01
3
Make many barplot into one plot
Dear all, ## I have 4 tables like this: satu <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4), dimnames=list(c("Negative", "Positive"), c("Black", "Brown", "Red", "Blond"))) dua <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4), dimnames=list(c("Negative", "Positive"),
2010 Nov 22
4
How to call R from C
Hi all! I read R Extensions manual. But still I am not sure how to call R functions from C. Would any of you give me a sample C code to show how to call R functions - for instance, time series functions - from C in the embedded way of C code? [[alternative HTML version deleted]]
2010 Jun 18
4
C Interface
Greetings, I am trying to call simple C-code from R. I am on Windows XP with RTools installed. The C-function is #include <R.h> #include <Rinternals.h> #include <Rmath.h> #include <Rdefines.h> // prevent name mangling extern "C" { SEXP __cdecl test(SEXP s){ SEXP result; PROTECT(result = NEW_NUMERIC(1)); double* ptr=NUMERIC_POINTER(result); double t =
2010 Mar 07
1
duplicate STRSXP : shallow copy ?
Hello, As this little program illustrates, duplicating a STRSXP does not seem deep enough. require( inline ) fx <- cfunction( signature( x = "character"), ' SEXP y = PROTECT( duplicate( x ) ); int n = LENGTH(x); int nc = 0 ; char* p = 0 ; for( int i=0; i<n; i++){ p = (char*)( CHAR( STRING_ELT( y , i ) ) ); nc = strlen( p ) ; for( int j=0; j<nc; j++){ p[j] =
2011 Nov 02
1
can one modify array in R memory from C++ without copying it?
Hi, guys. I posted this by accident at rcpp-dev, although it meant to be only to r-dev, so don't flame me here please, rcpp guys will do it there, i am sure :). I have some pretty large arrays in R and i wanted to do some time consuming modifications of these arrays in C++ without actually copying them, just by passing pointers to them. Since i don't know internal data structures of R, i
2010 Nov 28
1
faster base::sequence
Hello, Based on yesterday's R-help thread (help: program efficiency), and following Bill's suggestions, it appeared that sequence: > sequence function (nvec) unlist(lapply(nvec, seq_len)) <environment: namespace:base> could benefit from being written in C to avoid unnecessary memory allocations. I made this version using inline: require( inline ) sequence_c <- local( {
2011 Feb 06
5
Help with integrating R and c/c++
Hi, I have been using R for close to two years now and have grown quite comfortable with the language. I am presently trying to implement an optimization routine in R (Newton Rhapson). I have some R functions that calculate the gradient and hessian (pre requisite matrices) fairly efficiently. Now, I have to call this function iteratively until some convergance criterion is reached. I think the
2010 Oct 29
2
make many barplot into one plot
Dear R users I would like to group my barplot graph (see example on the R help link). The proposed R code, adding individual bars to the plot, looks really overwhelming. My specific dataset just consists of five groups and three different levels within each groups (the individual bars). The .txt file is read as matrix (horizontal: group, vertical: levels). The R trellis barchart (function
2014 Oct 31
3
ScalarLogical and setAttrib
Is it expected that attributes set on a LGLSXP created by ScalarLogical will apply to all future objects created by ScalarLogical as well? For example: the 'test1' function below returns FALSE and 'test2' returns FALSE with an attribute: library(inline) test1 <- cfunction(body = 'return ScalarLogical(0);') test2 <- cfunction(body = ' SEXP success =
2019 Sep 15
2
REprintf could be caught by tryCatch(message)
Dear R-devel community, There appears to be an inconsistency in R C API about the exceptions that can be raised from C code. Mapping of R C funs to corresponding R functions is as follows. error -> stop warning -> warning REprintf -> message Rprintf -> cat Rprint/cat is of course not an exception, I listed it just for completeness. The inconsistency I would like to report is
2010 Apr 13
2
Getting started with .C
Jeff Brown wrote: > > Hi, > > I'm trying to learn to use .C, which lets one invoke compiled C code from > within R. To do that, one has to first get the C code into R as a shared > object, which (I think) means first compiling it (with COMPILE or SHLIB) > and then loading it (with dyn.load()). > I would suggest taking it a step further and building an R package
2012 Mar 17
1
how to pass 'raw' values with cfunction()?
I am having trouble handing "raw" data to a C function, using "cfunction", as demonstrated in the function and output pasted below. Can anyone suggest what I'm doing incorrectly? Thanks. Dan Kelley [Dalhousie University]. 1. TEST FILE library(inline) code <- 'Rprintf("inside f(), b is 0X%x\\n", *b);' f <-
2019 Sep 15
2
[External] REprintf could be caught by tryCatch(message)
Thank you Luke for prompt reply. Is it possible then to request a new function to R C API "message" that would equivalent to R "message" function? Similarly as we now have C "warning" and C "error" functions. Best, Jan On Sun, Sep 15, 2019 at 5:25 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote: > > On Sun, 15 Sep 2019, Jan Gorecki wrote:
2020 Jun 30
2
Build a R call at C level
Hi All, I was reading the R extension manual section 5.11 ( Evaluating R expression from C) and I tried to build a simple call to the sum function. Please see below. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(2); return
2012 Nov 30
3
segfault debugging
Hello everybody, I have written a script with two inline cfunctions. The script crashes from time to time with: ? ?*** caught segfault *** ? address 0x10, cause 'memory not mapped' The crashs happen within R code after the cfunctions were executed. Nevertheless I think that the pointers in my cfunctions are not used correctly. I tried to find some examples for debugging tools. I found
2020 Jun 30
3
Build a R call at C level
On 6/30/20 1:06 PM, Jan Gorecki wrote: > It is quite known that R documentation on R C api could be improved... Please see "5.11 Evaluating R expressions from C" from "Writing R Extensions" Best Tomas > 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 <-