Displaying 5 results from an estimated 5 matches for "test_tryeval".
2006 Jul 11
2
Converting SEXP to primitive C types
...ing
the INTEGER(x), VECTOR_ELT(x,i), and similar functions found in /src/
include/Rinternals.h, but doing so results in incorrect results or a
seg-fault.
For example, I modified /tests/Embedding/Rerror.c so that it tries to
print the value returned by the function defined in error.R:
val = Test_tryEval(e, &errorOccurred);
printf("Returned: {%d}\n", VECTOR_ELT(val, 0) );
Where error.R is contains:
foo <-
function(x=3, y=6)
{
z <- x * y
z
}
But the output is just "0", not the correct "18". Any ideas?
Thanks for your help!
2004 Jun 11
1
bug or correct behaviour ?
This is the general outline of my code::
main(argc,argv){
...
Rf_initEmbeddedR(argc,argv);
...
Test_tryEval("source(test.r)");
...
}
#############
# test.r
#############
...
dyn.load("toload.so")
tmp <-matrix(data=1,nrow=narray*2,ncol=nclust)
.Call("Init",tmp,...)
while(...) {
criteria <-feval(tmp)
if (criteria < criteria.min)
tmp.last <- tmp...
2007 May 14
1
Best Practise
...way to copy
data, can I use memcpy/pointer assignment here to remove the loop without
running into garbage collector?
}
UNPROTECT( arrayToPassToR );
SEXP returnValueFromR;
(3) Have made it to call back to an R function which returns a new /
different SEXP double array.
returnValueFromR = Test_tryEval(...);
(4) Copy back to oldCArray
for(i=0; i < n; i++) {
oldCarray[i] = REAL(returnValueFromR)[i]; <--- can I use memcpy/pointer
assignment here to remove loop?
}
UNPROTECT(1);
I have done the long winded copy as I am a bit paranoid about the garbage
collection. My question is is it...
2006 May 25
1
compiling tests/Embedding
.../R-2.3.0/tests/Embedding> make
../../bin/R CMD LINK gcc -o Rtest Rtest.o embeddedRCall.o -L`cd ../.. &&
/bin/pwd`/lib -lR
gcc -o Rtest Rtest.o embeddedRCall.o
-L/autofs/tewa_data5/ost/R/R-2.3.0/lib -lR -Wl,--rpath
-Wl,/data5/ost/R/R-2.3.0/lib
embeddedRCall.o(.text+0x1e): In function `Test_tryEval':
/autofs/tewa_data5/ost/R/R-2.3.0/tests/Embedding/embeddedRCall.c:81:
undefined reference to `R_ToplevelExec'
collect2: ld returned 1 exit status
make: *** [Rtest] Error 1
ost at hawk0:/data5/ost/R/R-2.3.0/tests/Embedding> cd
/autofs/tewa_data5/ost/R/R-2.3.0/lib
ost at hawk0:/autofs/t...
2005 Feb 04
5
simple example of C interface to R
i'd like to use the C interface to R in a program i'm writing. as a
starting point, i'm trying to create a very simple C program that uses
R. i've read the R documentation on this, but i'm having trouble
figuring out where SEXP is defined and how to use it.
i noticed someone else on this list also tried to use the C interface,
but they ran into similar problems: