SCM

SCM Repository

[rmetrics] Diff of /pkg/randtoolbox/src/init.c
ViewVC logotype

Diff of /pkg/randtoolbox/src/init.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6032, Tue May 9 10:00:17 2017 UTC revision 6033, Wed May 10 08:47:02 2017 UTC
# Line 51  Line 51 
51   *   *
52   */   */
53    
54    #include <stdlib.h> //for NULL
55  #include <Rinternals.h>  #include <Rinternals.h>
56  #include <R_ext/Rdynload.h>  #include <R_ext/Rdynload.h>
 #include <R_ext/Visibility.h>  
57  #include "randtoolbox.h"  #include "randtoolbox.h"
58  #include "runifInterface.h"  #include "runifInterface.h"
59  #include "mt19937ar.h"  #include "mt19937ar.h"
# Line 61  Line 61 
61  #include "version.h"  #include "version.h"
62    
63  //table of registration routines accessed with .C()  //table of registration routines accessed with .C()
64  static const R_CMethodDef cMethods[] = {  static const R_CMethodDef CEntries[] = {
65    {"set_noop", (DL_FUNC) &set_noop, 0}, //runifInterface.h    {"set_noop", (DL_FUNC) &set_noop, 0}, //runifInterface.h
66    {"current_generator", (DL_FUNC) &current_generator, 1},    {"current_generator",           (DL_FUNC) &current_generator, 1}, //runifInterface.h
67    {"put_user_unif_set_generator", (DL_FUNC) &put_user_unif_set_generator, 0},    {"put_user_unif_set_generator", (DL_FUNC) &put_user_unif_set_generator, 0}, //runifInterface.h
68    {"get_state_congru", (DL_FUNC) &get_state_congru, 2}, //congruRand.h    {"get_state_congru", (DL_FUNC) &get_state_congru, 2}, //congruRand.h
69    {"put_state_congru", (DL_FUNC) &put_state_congru, 3},    {"put_state_congru",            (DL_FUNC) &put_state_congru, 3}, //congruRand.h
70    {"initMersenneTwister", (DL_FUNC) &initMersenneTwister, 4}, //mt19937ar.h    {"initMersenneTwister", (DL_FUNC) &initMersenneTwister, 4}, //mt19937ar.h
71    {"putMersenneTwister", (DL_FUNC) &putMersenneTwister, 3},    {"putMersenneTwister",          (DL_FUNC) &putMersenneTwister, 3}, //mt19937ar.h
72    {"getMersenneTwister", (DL_FUNC) &getMersenneTwister, 3},    {"getMersenneTwister",          (DL_FUNC) &getMersenneTwister, 3}, //mt19937ar.h
73    {"get_primes", (DL_FUNC) &get_primes, 2}, //randtoolbox.h    {"get_primes", (DL_FUNC) &get_primes, 2}, //randtoolbox.h
74    {"version_randtoolbox", (DL_FUNC) &version_randtoolbox, 1}, //version.h    {"version_randtoolbox", (DL_FUNC) &version_randtoolbox, 1}, //version.h
75    {NULL, NULL, 0}    {NULL, NULL, 0}
# Line 77  Line 77 
77    
78    
79  //table of registration routines accessed with .Call()  //table of registration routines accessed with .Call()
80  static const R_CallMethodDef callMethods[] =  static const R_CallMethodDef CallEntries[] =
81  {  {
82      {"doCongruRand",        (DL_FUNC) &doCongruRand, 6}, //randtoolbox.h
83      {"doHalton",            (DL_FUNC) &doHalton, 6}, //randtoolbox.h
84      {"doKnuthTAOCP",        (DL_FUNC) &doKnuthTAOCP, 2}, //randtoolbox.h
85      {"doSetSeed",           (DL_FUNC) &doSetSeed, 1}, //randtoolbox.h
86      {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4}, //randtoolbox.h
87      {"doSobol",             (DL_FUNC) &doSobol, 6}, //randtoolbox.h
88          {"doTorus", (DL_FUNC) &doTorus, 7}, //randtoolbox.h          {"doTorus", (DL_FUNC) &doTorus, 7}, //randtoolbox.h
89          {"doHalton", (DL_FUNC) &doHalton, 6},    {"doWELL",              (DL_FUNC) &doWELL, 5}, //randtoolbox.h
         {"doSobol", (DL_FUNC) &doSobol, 6},  
         {"doSetSeed", (DL_FUNC) &doSetSeed, 1},  
         {"doCongruRand", (DL_FUNC) &doCongruRand, 6},  
         {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4},  
         {"doWELL", (DL_FUNC) &doWELL, 5},  
         {"doKnuthTAOCP", (DL_FUNC) &doKnuthTAOCP, 2},  
90          {"doPokerTest", (DL_FUNC) &doPokerTest, 3}, //testrng.h          {"doPokerTest", (DL_FUNC) &doPokerTest, 3}, //testrng.h
91          {"doCollisionTest", (DL_FUNC) &doCollisionTest, 3},    {"doCollisionTest",     (DL_FUNC) &doCollisionTest, 3}, //testrng.h
92          {NULL, NULL, 0}          {NULL, NULL, 0}
93  };  };
94    
95  /* DOES NOT WORK => dynamic search  
96    /* .Fortran calls defined LowDiscrepancy.f
97     * C version of these Fortran routines are halton_c() and sobol_c() in randtoolbox.c
98     */
99    extern void F77_NAME(halton_f)(void *, void *, void *, void *, void *, void *, void *);
100    extern void F77_NAME(sobol_f)(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
101    
102  //table of registration routines accessed with .Fortran()  //table of registration routines accessed with .Fortran()
103  static const R_FortranMethodDef FortEntries[] = {  static const R_FortranMethodDef FortranEntries[] = {
104    {"halton", (DL_FUNC) &F77_NAME(halton),  7},    {"halton_f", (DL_FUNC) &F77_NAME(halton_f),  7},
105    {"sobol", (DL_FUNC) &F77_NAME(sobol),  11},    {"sobol_f", (DL_FUNC) &F77_NAME(sobol_f),  11},
106    {NULL, NULL, 0}    {NULL, NULL, 0}
107  };*/  };
108    
109    
110  //there is no routine accessed with .External()  //there is no routine accessed with .External()
# Line 107  Line 113 
113  void R_init_randtoolbox(DllInfo *dll)  void R_init_randtoolbox(DllInfo *dll)
114  {  {
115    //register method accessed with .C, .Call, .Fortran, .External respectively    //register method accessed with .C, .Call, .Fortran, .External respectively
116    R_registerRoutines(dll, cMethods, callMethods, NULL, NULL);    R_registerRoutines(dll, CEntries, CallEntries, FortranEntries, NULL);
117    R_useDynamicSymbols(dll, TRUE);    R_useDynamicSymbols(dll, FALSE);
118    
119    //make randtoolbox C functions available for other packages    //make randtoolbox C functions available for other packages
120    R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);    R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);
121    R_RegisterCCallable("randtoolbox", "halton", (DL_FUNC) halton);    R_RegisterCCallable("randtoolbox", "halton_c", (DL_FUNC) halton_c);
122    R_RegisterCCallable("randtoolbox", "sobol", (DL_FUNC) halton);    R_RegisterCCallable("randtoolbox", "sobol_c", (DL_FUNC) halton_c);
123    R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);    R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);
124    R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);    R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);
125    R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);    R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);

Legend:
Removed from v.6032  
changed lines
  Added in v.6033

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge