[R] Okay, here is what I am doing
satu
satu2021 at live.com.ar
Thu Apr 8 20:28:30 CEST 2010
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
> search()
[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
[1] 1 2 3 4 5 6 7 8 9 10
> n
[1] 10
> sigSq <- signature(n="integer", x="numeric")
> codeSq <- "
+ for (int i=0; i < *n; i++) {
+ x[i] = x[i]*x[i];
+ }"
> sigSq
n x
"integer" "numeric"
> codeSq
[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);
+ "
> sigQd
n x
"integer" "numeric"
> codeQd
[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.
--
View this message in context: http://n4.nabble.com/I-can-t-run-the-example-shown-in-the-inline-package-tp1774328p1778838.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list