Hi the list,
In a package P1, I write a function f1 in C, potentially an internal
function (not to be called from R).
In a package P2, I write a function f2 in C. The f2 function needs to
use f1 from P1. Is it possible ?
--- 8< ---- In file P1.c ---------
double f1(x,y){
....
}
--- 8< ---- In file P2.c ---------
void f2(x,y,z){
double result;
....
result = f1(x,y);
....
}
Thanks
Christophe
Hello, This was discussed this week in the thread "LinkingTo and C++". It is possible, and documented in WRE section 5.4 : http://cran.r-project.org/doc/manuals/R-exts.html#Registering-native-routines Romain On 02/14/2010 12:58 PM, Christophe Genolini wrote:> > Hi the list, > > In a package P1, I write a function f1 in C, potentially an internal > function (not to be called from R). > In a package P2, I write a function f2 in C. The f2 function needs to > use f1 from P1. Is it possible ? > > --- 8< ---- In file P1.c --------- > double f1(x,y){ > .... > } > > --- 8< ---- In file P2.c --------- > void f2(x,y,z){ > double result; > .... > result = f1(x,y); > .... > } > > Thanks > Christophe-- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/O1wO : highlight 0.1-5 |- http://tr.im/O1qJ : Rcpp 0.7.6 `- http://tr.im/NrTG : Rcpp 0.7.5
On 14 February 2010 at 12:58, Christophe Genolini wrote:
| Hi the list,
|
| In a package P1, I write a function f1 in C, potentially an internal
| function (not to be called from R).
| In a package P2, I write a function f2 in C. The f2 function needs to
| use f1 from P1. Is it possible ?
Yes. See 'Writing R Extension' on LinkingTo. You can register f1 for use
by
the others, if P2 has a LinkingTo: on P1 then you're good. The
'classic'
example is for lme4 using (large) parts of Matrix.
Dirk
| --- 8< ---- In file P1.c ---------
| double f1(x,y){
| ....
| }
|
| --- 8< ---- In file P2.c ---------
| void f2(x,y,z){
| double result;
| ....
| result = f1(x,y);
| ....
| }
|
| Thanks
| Christophe
|
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel
--
Registration is open for the 2nd International conference R / Finance 2010
See http://www.RinFinance.com for details, and see you in Chicago in April!