similar to: Question about calling C function from R

Displaying 20 results from an estimated 40000 matches similar to: "Question about calling C function from R"

2004 Jun 27
1
Re: help in R calling C function (Lei Liu)
> Message: 4 > Date: Sun, 27 Jun 2004 03:18:43 -0400 > From: Lei Liu <liulei at l.imap.itd.umich.edu> > Subject: [R] help in R calling C function > To: r-help at stat.math.ethz.ch > Message-ID: <5.1.0.14.1.20040627030746.014936b8 at l.imap.itd.umich.edu> > Content-Type: text/plain; charset="us-ascii"; format=flowed > > Hi there, > > I want
2010 Feb 12
1
R - Compiling and calling Fortran code that uses IMSL libraries - Help!
Good Afternoon R Help! On of my users is seriously thinking about moving to R from Splus. In his testing, he has already found some benefits to it. He has, however run into one issue, calling his Fortran functions in R. Previously, in Splus, he would do the following: 1. Compile via f90 the *.f program 2. link the object file to the Fortran IMSL libraries via the 'ld' command 3.
2009 Nov 20
1
how to link C code with gsl from R CMD and dyn.load
Hi, I am writing a function in C that is meant to be called by R. In the C function, I used a gsl function gsl_stats_mean. The code is as simple as below void gsl(double *m, int *dim){ int r, c; r = dim[0]; c = dim[1]; double mean = gsl_stats_mean(&m[0], 1, r); Rprintf("mean = %f\n", mean); } The C code is succesfully compiled and the output is as follows. $ R CMD SHLIB
2005 Apr 27
2
Problems compiling C code on windows
Hi all, I can't get my C routines running on a windows box. I have no problems at all in Linux. On windows, I have installed cygwin and the compilation works well but once I execute "dyn.load(.)" it hangs whatever I use C/C++ interfaces. In Linux it works wonderful but I need to get this code running on windows boxes. I know that the problem should be something with the
2004 Jun 15
2
loading multiple C files to R
Hi, I am willing to load multiple C files to R, which are inter-dependent (functions used in one may be defined in other). What I was trying is to first compile all of them separately (using R CMD SHLIB ...) and then load them one by one (using dyn.load("...") ), but it doesnt work (which seems to be obvious). During loading, it was unable to recognize the functions declared in
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 =
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 =
2005 Apr 14
1
question about "R get vector from C"
Dear ALL-R helpers, I want to let R get vector from c ,for example :numeric array ,vector .I saw some exmple like this : /* useCall3.c */ /* Getting an integer vector from C using .Call */ #include <R.h> #include <Rdefines.h> SEXP setInt() { SEXP myint; int *p_myint; int len = 5; PROTECT(myint = NEW_INTEGER(len)); // Allocating
2005 Jul 05
1
calling fortran functions CHOL and DPOTRF form Fortran
Hi all, I'm working out some Fortran code for which I want to compute the Choleski decomposition of a covariance matrix in Fortran. I tried to do it by two methods : 1) Calling the lapack function DPOTRF. I can see the source code and check that my call is correct, but it does not compile with: system("R CMD SHLIB ~/main.f") dyn.load("~/main.so") I get: Error in
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
2004 Apr 20
2
compile Fortran code which calls C subroutine
I used "R CMD SHLIB" to compile the fortran filename.f file and the filename.so is generated. But since in filename.f it calls another subroutine written in C, i had problem in "dyn.load" because it could not find the C subroutine. I have the .c file but don't know how to tell R about it. How should I compile when I want to call the fortran function
2004 Jun 27
1
help in R calling C function
Hi there, I want to call a C function in R. I have some experience on it, but this time I need to call another C function in the "main" C function. As a simple example, I use the following C code: #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> void main(double *alpha) { double test(); double beta; beta= *alpha *2 +
2001 Sep 14
1
Dynamic loading problem.
I'm having a dynamic loading problem that seems to be caused by exponentiation (the ** operator in Fortran/ratfor). This can be illustrated by the following toy example: ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+=== % cat foo.r subroutine foo(x,n) x = x**n return end % f77 -c foo.r /tmp/ratfor.06661.0.f: foo: % R CMD SHLIB -o foo.so foo.o gcc -G -o
2009 Jan 10
2
Problem with compiling shared C/C++ library for loading into R (Linux)
I am using the .Call interface to call c++ code from R. For that, I am trying to create a dynamic library (mylib.so) using "R CMD SHLIB" by linking my own c++ code and an external c++ library (blitz++). The makefile works fine on my Mac, produces mylib.so and I am able to call .Call() from R, but on a linux server (I think Debian), I got the following error: ---------- /usr/bin/ld:
2009 Jan 10
2
Problem with compiling shared C/C++ library for loading into R (Linux)
I am using the .Call interface to call c++ code from R. For that, I am trying to create a dynamic library (mylib.so) using "R CMD SHLIB" by linking my own c++ code and an external c++ library (blitz++). The makefile works fine on my Mac, produces mylib.so and I am able to call .Call() from R, but on a linux server (I think Debian), I got the following error: ---------- /usr/bin/ld:
2009 Sep 04
1
calling Lapack and BLAS routines from C
Hi, I am working on a UNIX machine and I am interfacing R and C with the .C function. I am trying to call LAPACK and BLAS routines, but am running into a problem where, while I am able to run the BLAS routines, I cannot run the LAPACK routines. I compile my .c file (at end of email) in the following way: [mhitczen at jlogin2 ~/Cstuff]$ R CMD SHLIB testmore.c gcc -std=gnu99
2008 Nov 04
1
Help needed using 3rd party C library/functions from within R (Nvidia CUDA)
Hello, I'm trying to combine the parallel computing power available through NVIDIA CUDA (www.nvidia.com/cuda) from within R. CUDA is an extension to the C language, so I thought it would be possible to do this. If I have a C file with an empty function which includes a needed CUDA library (cutil.h) and compile this to an .so file using a NVIDIA compiler (nvcc), called 'myFunc.so' I
2002 Nov 18
1
i386 floating point tweaking
Just been trying to get the polygon triangulation code from this package: http://www-2.cs.cmu.edu/~quake/triangle.html to dyn.load into R. Uh oh. Floating point exceptions. Track it down to some FPU diddling that the author deems is necessary. Here's my minimal code that breaks: flipme.c: #include <fpu_control.h> void flipme(){ int cword; cword=4210; _FPU_SETCW(cword);
2001 Feb 27
1
using fmod in C code to be loaded into R
Dear People, I wrote the following bit of C code and (along with other bits) called it mycode.c, and compiled the file into a shared library to load into R, using R CMD SHLIB mycode.c. This was Ok, but when I tried to load this into R using dyn.load("mycode.so") I got the error > dyn.load("mycode.so") Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to
2011 Apr 20
2
Include C++ DLL, error in ...: C symbol name not in load table
Hello R experts I am googling and reading around, however, I can't get it working (perhaps because I do not understand much C, however, I'll give it a try). I am trying to include C++ code into an R routine, where the C++ code looks: #include <iostream> using namespace std; void foo (double* x, double* y, double* out) { out[0] = x[0] + y[0]; } Back in R, the command R CMD