search for: returned_data

Displaying 6 results from an estimated 6 matches for "returned_data".

2006 Dec 02
1
Trouble passing arrays to C code
...ion: void lorenz_run_R_wrapper(double *x0, double *y0, double *z0, double *h, double *steps, double *res_x, double *res_y, double *res_z) { lorenz_run(*x0, *y0, *z0, *h, *steps, res_x, res_y, res_z); } The corresponding R wrapper function is: lorenz_run <- function(x0,y0,z0,h,steps) { returned_data = .C("lorenz_run_R_wrapper", x0=as.double(x0), y0=as.double(y0), z0=as.double(z0), h=as.double(h), steps=as.integer(steps), res_x=double(steps),...
2009 Aug 28
1
Calling C funtion from R help Needed
...clude <stdio.h> #include<string.h> int n_char(char ,int ); void checkstr_R_wrapper(char *n,int *m, int *result) { *result = n_char(*n,*m); } R code (checkstr.c) checkstr <- function(n,m) { if (!is.loaded(symbol.C('checkstr_R_wrapper'))) { dyn.load('checkstr.so') } returned_data = .C('checkstr_R_wrapper', n=as.character(n),m=as.integer(m), result=integer(1)) return(returned_data$result) } result in R > source('checkstr.R') > checkstr('a',3) Warning in symbol.C("checkstr_R_wrapper") : 'symbol.C' is not needed: please remove...
2009 Sep 11
1
call Fortran from R
...END SUBROUTINE Then I compiled all this stuff g77 -fno-second-underscore -c -fPIC model.f g77 -fno-second-underscore -c -fPIC wrapper.f g77 -fno-second-underscore -shared -o model.so model.o wrapper.o From within R dyn.load('model.so') model <- function(times, alfa, beta) { returned_data = .Fortran('model_wrapper', times=as.double(times), alfa=as.double(alfa), beta=as.double(beta), result=double(1)) return(returned_data) } # example run test_1<-model(1.0,0.2,0.3) which gives test_1$times [1] 1.0 $alfa [1] 0.2 $beta [1] 0.3 $result [1] 147456887 where $re...
2008 Feb 14
0
passing R array to Fortran subroutine
...INTEGER :: i ! answer = factorial(n) do i=1,3 n(i) = n(i) + i/1.0 end do END SUBROUTINE testRwrapper ====== test.R ====== foo <- function(n) { # If the library hasn't been loaded yet, load it if (!is.loaded('testRwrapper')) { dyn.load('foo.dylib') } returned_data = .Fortran('testRwrapper', n=as.double(n))#, # Return the value of the result parameter return(returned_data$n) } ====== R result ====== > source('test.R') > foo(c(1.1, 2.2, 3.3, 4.4)) *** caught segfault *** address 0x3ff19999, cause 'memory not mapped' T...
2012 Oct 20
1
Trouble returning 2D array into R from Fortran
...e Fortran. I've tried putting the Fortran function call inside an R function, with this syntax; #Source positions in lens plane under annual parallax xypos_parallax <- function(year,ra,dec,ti,model_par) { if (!is.loaded('xypos_parallax_r')){ dyn.load('parallax.so')} returned_data = .Fortran('xypos_parallax_r', as.integer(length(ti)), as.integer(year), as.double(ra), as.double(dec), as.double(ti), as.double(model_par$t0),...
2009 Sep 11
3
For sending my R package as part of R-project
...END SUBROUTINE Then I compiled all this stuff g77 -fno-second-underscore -c -fPIC model.f g77 -fno-second-underscore -c -fPIC wrapper.f g77 -fno-second-underscore -shared -o model.so model.o wrapper.o From within R dyn.load('model.so') model <- function(times, alfa, beta) { returned_data = .Fortran('model_wrapper', times=as.double(times), alfa=as.double(alfa), beta=as.double(beta), result=double(1)) return(returned_data) } # example run test_1<-model(1.0,0.2,0.3) which gives test_1$times [1] 1.0 $alfa [1] 0.2 $beta [1] 0.3 $result [1] 147456887 where $res...