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 6028, Wed May 3 19:42:06 2017 UTC revision 6136, Tue Apr 30 12:56:05 2019 UTC
# Line 8  Line 8 
8   *   *
9   * Copyright (C) 2017, Christophe Dutang,   * Copyright (C) 2017, Christophe Dutang,
10   * Petr Savicky, Academy of Sciences of the Czech Republic.   * Petr Savicky, Academy of Sciences of the Czech Republic.
11     * Christophe Dutang, see http://dutangc.free.fr
12   * All rights reserved.   * All rights reserved.
13   *   *
14   * The new BSD License is applied to this software.   * The new BSD License is applied to this software.
# Line 51  Line 52 
52   *   *
53   */   */
54    
55    #include <stdlib.h> //for NULL
56  #include <Rinternals.h>  #include <Rinternals.h>
57  #include <R_ext/Rdynload.h>  #include <R_ext/Rdynload.h>
58  #include "randtoolbox.h"  #include "randtoolbox.h"
59  #include "runifInterface.h"  #include "runifInterface.h"
60    #include "mt19937ar.h"
61  #include "testrng.h"  #include "testrng.h"
62    #include "version.h"
63    
64  //table of registration  //table of registration routines accessed with .C()
65  static const R_CallMethodDef callMethods[] =  static const R_CMethodDef CEntries[] = {
66      {"set_noop",                    (DL_FUNC) &set_noop, 0}, //runifInterface.h
67      {"current_generator",           (DL_FUNC) &current_generator, 1}, //runifInterface.h
68      {"put_user_unif_set_generator", (DL_FUNC) &put_user_unif_set_generator, 0}, //runifInterface.h
69      {"get_state_congru",            (DL_FUNC) &get_state_congru, 2}, //congruRand.h
70      {"put_state_congru",            (DL_FUNC) &put_state_congru, 3}, //congruRand.h
71      {"initMersenneTwister",         (DL_FUNC) &initMersenneTwister, 4}, //mt19937ar.h
72      {"putMersenneTwister",          (DL_FUNC) &putMersenneTwister, 3}, //mt19937ar.h
73      {"getMersenneTwister",          (DL_FUNC) &getMersenneTwister, 3}, //mt19937ar.h
74      {"get_primes",                  (DL_FUNC) &get_primes, 2}, //randtoolbox.h
75      {"version_randtoolbox",         (DL_FUNC) &version_randtoolbox, 1}, //version.h
76      {NULL, NULL, 0}
77    };
78    
79    
80    //table of registration routines accessed with .Call()
81    static const R_CallMethodDef CallEntries[] =
82  {  {
83          {"doTorus", (DL_FUNC) &doTorus, 7},    {"doCongruRand",        (DL_FUNC) &doCongruRand, 6}, //randtoolbox.h
84          {"doHalton", (DL_FUNC) &doHalton, 6},    {"doHalton",            (DL_FUNC) &doHalton, 6}, //randtoolbox.h
85          {"doSobol", (DL_FUNC) &doSobol, 6},    {"doKnuthTAOCP",        (DL_FUNC) &doKnuthTAOCP, 2}, //randtoolbox.h
86          {"doSetSeed", (DL_FUNC) &doSetSeed, 1},    {"doSetSeed",           (DL_FUNC) &doSetSeed, 1}, //randtoolbox.h
87          {"doCongruRand", (DL_FUNC) &doCongruRand, 6},    {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4}, //randtoolbox.h
88          {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4},    {"doSobol",             (DL_FUNC) &doSobol, 6}, //randtoolbox.h
89          {"doPokerTest", (DL_FUNC) &doPokerTest, 3},    {"doTorus",             (DL_FUNC) &doTorus, 7}, //randtoolbox.h
90          {"doCollisionTest", (DL_FUNC) &doCollisionTest, 3},    {"doWELL",              (DL_FUNC) &doWELL, 5}, //randtoolbox.h
91          {"doWELL", (DL_FUNC) &doWELL, 5},    {"doPokerTest",         (DL_FUNC) &doPokerTest, 3}, //testrng.h
92          {"doKnuthTAOCP", (DL_FUNC) &doKnuthTAOCP, 2},    {"doCollisionTest",     (DL_FUNC) &doCollisionTest, 3}, //testrng.h
93      {NULL, NULL, 0}
94    };
95    
96    
97    /* .Fortran calls defined LowDiscrepancy.f
98     * C version of these Fortran routines are halton_c() and sobol_c() in randtoolbox.c
99     */
100    /* DOES NOT WORK*/
101    extern void F77_NAME(halton_f)(void *, void *, void *, void *, void *, void *, void *);
102    extern void F77_NAME(sobol_f)(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
103    
104    //table of registration routines accessed with .Fortran()
105    static const R_FortranMethodDef FortranEntries[] = {
106      {"halton_f", (DL_FUNC) &F77_NAME(halton_f),  7}, //LowDiscrepancy.f
107      {"sobol_f", (DL_FUNC) &F77_NAME(sobol_f),  11}, //LowDiscrepancy.f
108          {NULL, NULL, 0}          {NULL, NULL, 0}
109  };  };
110    
111    
112  //table of registered routines  //there is no routine accessed with .External()
113  void R_init_randtoolbox(DllInfo *info)  
114    //table of all registered routines
115    void R_init_randtoolbox(DllInfo *dll)
116  {  {
117          //register method accessed with .Call    //register method accessed with .C, .Call, .Fortran, .External respectively
118          R_registerRoutines(info, NULL, callMethods, NULL, NULL);    R_registerRoutines(dll, CEntries, CallEntries, FortranEntries, NULL);
119    
120      /*dynamic lookup only for
121      double *user_unif_rand(void);
122      void user_unif_init(unsigned int seed);
123      in src/runifInterface.h*/
124      R_useDynamicSymbols(dll, TRUE);
125    
126    
127          //make randtoolbox C functions available for other packages          //make randtoolbox C functions available for other packages
128          R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);          R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);
129          R_RegisterCCallable("randtoolbox", "halton", (DL_FUNC) halton);    R_RegisterCCallable("randtoolbox", "halton_c", (DL_FUNC) halton_c);
130          R_RegisterCCallable("randtoolbox", "sobol", (DL_FUNC) halton);    R_RegisterCCallable("randtoolbox", "sobol_c", (DL_FUNC) sobol_c);
131          R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);          R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);
132          R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);          R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);
133          R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);          R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);
# Line 91  Line 135 
135          R_RegisterCCallable("randtoolbox", "collisionTest", (DL_FUNC) collisionTest);          R_RegisterCCallable("randtoolbox", "collisionTest", (DL_FUNC) collisionTest);
136          R_RegisterCCallable("randtoolbox", "knuthTAOCP", (DL_FUNC) knuthTAOCP);          R_RegisterCCallable("randtoolbox", "knuthTAOCP", (DL_FUNC) knuthTAOCP);
137    
138                  //retrieve WELL rng entry point in the rngWELL pkg    //retrieve RNG function coming from rngWELL package, see files rngWELL.c(h) in that pkg
139                  WELLrng = (void (*) (double *, int, int, int, int, int)) R_GetCCallable("rngWELL", "WELLrng");                  WELLrng = (void (*) (double *, int, int, int, int, int)) R_GetCCallable("rngWELL", "WELLrng");
140                  WELL_get_set_entry_point =(void (*) (void (*)())) R_GetCCallable("rngWELL", "WELL_get_set_entry_point");                  WELL_get_set_entry_point =(void (*) (void (*)())) R_GetCCallable("rngWELL", "WELL_get_set_entry_point");
141                  /*getRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "getRngWELL");    /* // well RNG function coming from rngWELL package, see files runifInterface.c(h) in that pkg
142      getRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "getRngWELL");
143                  putRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "putRngWELL");                  putRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "putRngWELL");
144                  initMT2002 = (void (*) (unsigned int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "initMT2002");*/                  initMT2002 = (void (*) (unsigned int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "initMT2002");*/
145    
146    
147  }  }
148    

Legend:
Removed from v.6028  
changed lines
  Added in v.6136

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