All is done in R 2.10.1 wiht the package "inline" version 0.3.4,,,
this are the packages that I have loaded into the workspace
[1] ".GlobalEnv" "package:inline" "package:stats"
"package:graphics" "package:grDevices" "package:datasets" "package:rcom"
[8] "package:rscproxy" "package:utils" "package:methods" "Autoloads"
"package:base"
This is pure copy and paste from the PDF file
x<- as.numeric(1:10)
n<- as.integer(10)
x
sigSq<- signature(n="integer", x="numeric")
codeSq<- "
+ for (int i=0; i< *n; i++) {
+ x[i] = x[i]*x[i];
+ }"
[1] "\nfor (int i=0; i< *n; i++) {\nx[i] = x[i]*x[i];\n}"
sigQd<- signature(n="integer", x="numeric")
codeQd<- "
+ squarefn(n, x);
+ squarefn(n, x);
+ "
[1] "\nsquarefn(n, x);\nsquarefn(n, x);\n"
fns<- cfunction( list(squarefn=sigSq, quadfn=sigQd),
+ list(codeSq, codeQd),
+ convention=".C")
ERROR(s) during compilation: source code errors or compiler configuration
errors!
Program source:
1: #include<R.h>
2:
3:
4: extern "C" {
5: void squarefn ( int * n, double * x );
6: }
7:
8: void squarefn ( int * n, double * x ) {
9:
10: for (int i=0; i< *n; i++) {
11: x[i] = x[i]*x[i];
12: }
13: }
14: extern "C" {
15: void quadfn ( int * n, double * x );
16: }
17:
18: void quadfn ( int * n, double * x ) {
19:
20: squarefn(n, x);
21: squarefn(n, x);
22:
23: }
Error in compileCode(f, code, language, verbose) :
Compilation ERROR, function(s)/method(s) not created!
Following the example shown in this PDF,,, after the fns<- cfunction( ,,, )
follows:
squarefn<- fns[["squarefn"]]
quadfn<- fns[["quadfn"]]
squarefn(n, x)$x
quadfn(n, x)$x
but the compile error shows up right after the cfunction(,,,) sentence.