Calling fortran from R via C does not link -
i have routine in fortran, wish use in r via c implementation. suppose fortran file bivnt.f. now, r cmd shlib c_binary.c
, r cmd shlib bivnt.f
not give problem when comes linking obtain
> dyn.load("bivnt.so") > dyn.load("c_binary.so") errore in dyn.load("c_binary.so") : unable load shared object '/users/erlisruli/dropbox/wpapers/abc-cs/rcode/corbindata/c_binary.so': dlopen(/users/erlisruli/dropbox/wpapers/abc-cs/rcode/corbindata/c_binary.so, 6): symbol not found: _smvbvt_ referenced from: /users/erlisruli/dropbox/wpapers/abc-cs/rcode/corbindata/c_binary.so expected in: flat namespace in /users/erlisruli/dropbox/wpapers/abc-cs/rcode/corbindata/c_binary.so
this seems pretty strange me, since nm obtain
$ nm bivnt.so 0000000000003940 s _a.1868 u _asin u _atan u _atan2 u _exp 0000000000003540 t _mvbvn_ 00000000000027a0 t _mvbvt_ 0000000000002610 t _mvbvtc_ 0000000000002040 t _mvbvtl_ 0000000000002d10 t _mvbvu_ 0000000000001f20 t _mvphi_ 0000000000002b80 t _mvstdt_ u _sin 00000000000038a0 t _smvbvt_ 0000000000003ba0 s _w.1368 0000000000003aa0 s _x.1369 u dyld_stub_binder
any clue?
p.s. c_binary.c is
#include<r.h> /* calcolo ripartizione normale bivariata */ void f77_sub(smvbvt)( double* , int* , double*, double* , int* , double* ) ; void biv_pmnorm( double *prob , int *nu, double *lower , double *upper , int *flag , double *corr ) { f77_call(smvbvt)( prob , nu , lower , upper , flag , corr ) ; } //pairwise log-likelihood-->output: units void bin_pairwise_llik( double *res , double *data , double *cov, double *theta , int *n , int *nc ) /* n = #righe ; nc = #colonne*/ { register int k, i, j, ite=0; int nu=0, flag[2]; double res2=0.0 , res3=0.0, corr=theta[2], lower[2], upper[2]; for( k=0; k<*n; k++ ) { for( i=0; i<(*nc-1); i++ ) { for( j=(i+1); j<*nc; j++ ) { if(*(data + + k**nc)==1) { lower[0] = -*(theta+0)-*(theta+1)**(cov + + k**nc); upper[0] = 0.0; flag[0] = 1; } else { lower[0] = 0.0; upper[0] = -*(theta+0)-*(theta+1)**(cov + + k**nc); flag[0] = 0; } if(*(data + j + k**nc)==1) { lower[1] = -*(theta+0)-*(theta+1)**(cov + j + k**nc); upper[1] = 0.0; flag[1] = 1; } else { lower[1] = 0.0; upper[1] = -*(theta+0)-*(theta+1)**(cov + j + k**nc); flag[1] = 0; } biv_pmnorm( &res2, &nu, lower, upper, flag, &corr ) ; res3+=log(res2); ite += 1; } } res[k]=res3; res3=0.0; } } //pairwise log-likelihood-->output: 1 value void bin_pairwise_llik_sum( double *res , double *data , double *cov, double *theta , int *n , int *nc ) /* n = #righe ; nc = #colonne*/ { register int k, i, j, ite=0; int nu=0, flag[2]; double res2=0.0 , corr=theta[2], lower[2], upper[2]; *res=0.0; for( k=0; k<*n; k++ ) { for( i=0; i<(*nc-1); i++ ) { for( j=(i+1); j<*nc; j++ ) { if(*(data + + k**nc)==1) { lower[0] = -*(theta+0)-*(theta+1)**(cov + + k**nc); upper[0] = 0.0; flag[0] = 1; } else { lower[0] = 0.0; upper[0] = -*(theta+0)-*(theta+1)**(cov + + k**nc); flag[0] = 0; } if(*(data + j + k**nc)==1) { lower[1] = -*(theta+0)-*(theta+1)**(cov + j + k**nc); upper[1] = 0.0; flag[1] = 1; } else { lower[1] = 0.0; upper[1] = -*(theta+0)-*(theta+1)**(cov + j + k**nc); flag[1] = 0; } biv_pmnorm( &res2, &nu, lower, upper, flag, &corr ) ; *res+=log(res2); ite += 1; } } } }
Comments
Post a Comment