search for: rdefin

Displaying 20 results from an estimated 108 matches for "rdefin".

Did you mean: defin
1999 Oct 27
1
Rdefines.h
Hi all, may I request the following two changes to Rdefines.h (R 0.65.1)? 1.) Change line 106 from #define Free(p) R_chk_free( (void *)(p) ) to #define Free(p) R_chk_free( (void *)(p) ) , p=NULL 2.) Add after line 79: #define PROBLEM {char R_problem_buf[R_PROBLEM_BUFSIZE];sprintf(R_problem_buf, a new line 80: #define PROB...
2013 May 24
1
Problem with Rboolean in c++ code
...ile using R CMD SHLIB: g++ -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe -g -c rboolean.cpp -o rboolean.o rboolean.cpp: In function ?SEXPREC* create(SEXP)?: rboolean.cpp:21:46: error: invalid conversion from ?int? to ?Rboolean? [-fpermissive] In file included from /usr/share/R/include/Rdefines.h:29:0, from rboolean.cpp:4: /usr/share/R/include/Rinternals.h:764:6: error: initializing argument 3 of ?void R_RegisterCFinalizerEx(SEXP, R_CFinalizer_t, Rboolean)? [-fpermissive] make: *** [rboolean.o] Error 1 I have managed to reduce the problem to the example below:...
2005 Dec 21
1
linking C and R
...ave written some C code that I would like to use dynload to bring into R. When I try to compile the code i get the error R.defines.h no such file or directory. I know that the file is in resources/include but where do I have to move the file to so that the compiler can access it? I tried copying Rdefines.h and R_ext folders into the folder where the code is and using" #include "Rdefines.h" instead of #include <Rdefines.h>. I now get a different error R_ext/Memory.h: no such file or directory even though r_ext is in the folder. Any suggestions? Thanks, Eliza...
2005 Aug 20
1
Implementing a single-precision class with raw
...on data type is okay. I've run into a limitation with the .C() function where it does not handle raw vectors, which it will do in 2.2.0. In the meantime, I'm using the .Call() function to access the raw vectors. However, there don't seem to be any macros for handling raw vectors in Rdefines.h. I've made a guess at what those macros would be and was wondering whether my guesses were correct and/or might be included in 2.2.0: #define NEW_RAW(n) allocVector(RAWSXP,n) #define RAW_POINTER(x) (RAW(x)) #define AS_RAW(x) coerceVector(x,RAWSXP) I'm not sure whether coerceVector(x...
2008 Mar 15
1
Experimental R_has_slot() utility
...e file NEWS ("Experimental R_has_slot() utility supplementing R_do_slot()") appears to be missing from a fresh checkout of the development branch. $ svn up At revision 44759. $ grep -i has_slot `find include -name '*.h'` $ grep -i _slot `find include -name '*.h'` include/Rdefines.h:#define GET_SLOT(x, what) R_do_slot(x, what) include/Rdefines.h:#define SET_SLOT(x, what, value) R_do_slot_assign(x, what, value) include/Rinternals.h:SEXP R_do_slot(SEXP obj, SEXP name); include/Rinternals.h:SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value); ..or did I miss it ?...
2007 Apr 03
3
Strange number produced by dnorm
Hi All, I just started to learn compiling C codes for R usage, and got a problem when I was playing with my 'hello world' code. #include <R.h> #include <Rdefines.h> #include <Rmath.h> SEXP test( ) { double x; x=dnorm(1.0,0.0,1.0,1); printf(" x value is: %d \n",x); return(R_NilValue); } I got the result : x value is: -466460838 Could someone explain to me what was wrong here ? Thanks a lot. tong
2004 Jun 16
1
Compiling C++ package source: linking problem?
...ving followed the instructions in readme.packages, my code compiles fine with R CMD SHLIB (as well as R CMD check) ... until I start using the internal R functions. (Interesting: Rprintf seems to be the exception.) For instance, the following code compiles fine: #include <R.h> #include <Rdefines.h> ... SEXP whatever (SEXP model) { Rprintf ("Hello, here I am!\n"); return model; } However, the following doesn't compile at all: #include <R.h> #include <Rdefines.h> ... SEXP whatever (SEXP model) { SEXP anotherModel; PROTECT(anotherModel = NEW_NUMERIC...
2008 Apr 18
1
R-extension in unix system -- help to locate header files
Hi list, To call C, I used to use R-extension in windows but I'm moving to unix system because my PC doesn't have enough memory. My C codes requires to include the following header files: #include <stdlib.h> #include <R.h> #include <Rdefines.h> #include <Rmath.h> #include <R_ext/Applic.h> #include <R_ext/PrtUtil.h> In windows, I had no problem with it because I set the path for Rtools and R etc. But in unix system, these header files call other header files and they call other header files... And some files are...
2004 Apr 26
1
Segfault: .Call and classes with logical slots
Hi, the following example aiming at a class containing a logical slot segfaults under R-1.9.0 when `gctorture(on = TRUE)' is used: Code code (dummy.c): #include <Rdefines.h> SEXP foo() { SEXP ans; PROTECT(ans = NEW_OBJECT(MAKE_CLASS("test"))); SET_SLOT(ans, install("lgl"), allocVector(LGLSXP, 1)); LOGICAL(GET_SLOT(ans, install("lgl")))[0] = TRUE; UNPROTECT(1); return(ans); } R code (dummy.R): dyn.load(&...
2008 Mar 20
1
Rmpi and C Code, where to get the communicator
...code looks something like this: library(Rmpi) mpi.spawn.Rslaves() mpi.remote.exec(....) dyn.load("test.so") erg <- .Call("test", ....) .... mpi.close.Rslaves() mpi.quit() And my C function looks something like this: #include <mpi.h> #include <R.h> #include <Rdefines.h> #include <Rinternals.h> SEXP test (SEXP a, ..){ int rank; comm ?????? MPI_Comm_rank (comm, &rank); ...... } For all MPI functions I need the right communicator (MPI_Comm *comm;) to communicate with the existing slaves. This variable will be generated by spawning...
2003 Oct 31
2
How to grow an R object from C (.Call Interface)
What is the best way to grow an R return object in writing a C function using the Rdefines.h macros. In my application, the final size of the return object is not known during construction. My understanding is that each time I grow an R object I have to use PROTECT() again, probably before UNPROTECTing the smaller version. However, due to the stack character of the PROTECT mechanism, U...
2006 Apr 12
0
headerfile translation to Delphi (Pascal) completed
...---------------------- Convolve -------- The first demo presents the convolve examples from the manual "Writing R Extensions" in a "Delphi-translated" version. The three interface functions .C, .Call and .External are used and the application of some macros in Rinternals.h and Rdefines.h (which become rhRInternal.pas and rhRDefines.pas) is shown. RegisteredConvolve ------------------ "RegisteredDemoEx.dll" shows how to register a Delphi function in the "R_init_<dll-name>" call. [The RegisteredConvDemo was the first attempt but the freely called reg...
2003 Nov 16
2
Error when calling a dll procedure
...ome part of the source code (of an implementation of a function to find all primes below a given numeric value -> its just an exercises to get familar with R/C++). >#include <vector> > >using namespace std; > >extern "C" { >#include <R.h> >#include <Rdefines.h> >} > >SEXP getPrimes(SEXP a) >{ >SEXP c; > //my implementation > >return c; >} Here is the output (hopefully without any typos) of the process building the dll: >Rcmd SHLIB Primes.cc >making Primes.d from Primes.c >g++ -IE:\programs\R\rw1071\src\inc...
2001 Sep 10
1
problems linking c++ code
...=================== .First.lib <- function(libpath, libname) { library.dynam(libname) } read.landscape <- function(fn = "filename") { .Call("read_landscape",fn,PACKAGE = "rmetasim") } C-code =================== #include <R.h> #include <Rdefines.h> #include <Rinternals.h> #ifdef __cplusplus extern "C" SEXP read_landscape(SEXP fn); extern "C" { #endif SEXP read_landscape(SEXP fn) { SEXP l; PROTECT(l = allocVector (REALSXP, 2)); REAL(l)[0] = 12.0; REAL(l)[1] =14.5; UNPROTECT(1); return l; } #ifde...
2009 Sep 16
2
I want to get a reference to this time series object
...ct with the array subscripts like above. Here is what I tried to do. It doesn't work because "[" is obviously not an operation or function on SWX.RET. So how do I get a reference to this object? #include <stdio.h> #include <R.h> #include <Rinternals.h> #include <Rdefines.h> #include <Rembedded.h> int main(int argc, char** argv) { SEXP e,c,portSpec,portData,portConstr,portVal,tsAssets; int errorOccurred,nx,ny,i,j; double *v; const char *x,*y; Rf_initEmbeddedR(argc, argv); // loading fPortfolio PROTECT(e = lang2(install(&quo...
2003 Jan 03
1
Interfacing R and C++ under Windows
Dear all, My colleague, who has been helping me with wrapping some older C++ code for use in R, has been running into some issues, which he asked me to post here: - ERROR is defined in RS.h which is included in Rdefines.h which conflicts with Visual Studio's ERROR - TRACE is defined in Rinternals.h which conflicts with Visual Studio's TRACE - math.h is included within extern "C" linkage in R.h, however Visual Studio's math.h includes templates which are only valid in C++ Basically, he feel...
2003 Nov 18
1
How to return a big treelike list from .Call Interface (protect stack overflow)
I try to create a big treelike list structure using the RDefines/RInternal macros. The tree carries information at each node (attribute list) and at each leaf (vector). My understanding is that for each node I add to the binary tree I have to call PROTECT(newnode = NEW_LIST(2)); and cannot UNPROTECT before I return the whole tree. Same story for node attr...
2004 Feb 11
1
About the macro defined in Rinternals.h
Hello everyone, I try to write a c++ code which calls embedded R and uses some of R internal functions. What I read is just lots of macro names defined in the Rinternals.h or Rdefines like R_Parse, Rf_install and so on. But where can I get the detailed information about the parameters of these macro? For example, what about the parameters of SEXP R_ParseVector(SEXP, int, ParseStatus *)? Thank you very much! Baiyi Song Computer Engineering Institute Dortmund Univercity
2004 Feb 26
1
Handling R Objects in C
...m a C/C++ project developped with Microsoft Visual C++.Net I put a multiproject solution,and one project is a win32 and dedicated for R manipulation; When I put in this project the example code from "Written R extension" 4.7 Handling R objects in C p39: #include <R.h> #include <Rdefines.h> SEXP ab; PROTECT(ab=NEW_NUMERIC(2)) ; .... I got an unresolved external in the link, because I don't know what I need to declare as an external library,I searched in the documentation but I didn't find Could you please help me Thank a lot by advance Pascal
2006 May 08
1
Calling C++ code fom R --How to export C++ "unsigned" integer to R?
...d in C++) ). I know that to export signed integer to R, I can do the following in C++: int Some_INTEGER = 5; int *p_myInt; SEXP myInt; PROTECT(myInt=NEW_INTEGER(1)); myInt[0] = Some_INTEGER; UNPROTECT(1); return myInt; However, it appears that myInt is a signed integer. I have looked over Rdefines.h and it does not look like there is a definition for NEW_UNSIGNED_INTEGER ! How would I export an unsigned integer to R? obviously this won't work: unsigned int Some_INTEGER = 5; unsigned int *p_myInt; SEXP myInt; PROTECT(myInt=NEW_INTEGER(1)); myInt[0] = Some_INTEGER; UNPROTECT(1);...