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 5188, Thu Jan 12 11:22:51 2012 UTC revision 6032, Tue May 9 10:00:17 2017 UTC
# Line 6  Line 6 
6   * @author Petr Savicky   * @author Petr Savicky
7   *   *
8   *   *
9   * Copyright (C) 2009, 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   * All rights reserved.   * All rights reserved.
12   *   *
13   * The new BSD License is applied to this software.   * The new BSD License is applied to this software.
14   * Copyright (c) 2009 Christophe Dutang, Petr Savicky.   * Copyright (c) 2013 Christophe Dutang, Petr Savicky.
15   * All rights reserved.   * All rights reserved.
16   *   *
17   *      Redistribution and use in source and binary forms, with or without   *      Redistribution and use in source and binary forms, with or without
# Line 53  Line 53 
53    
54  #include <Rinternals.h>  #include <Rinternals.h>
55  #include <R_ext/Rdynload.h>  #include <R_ext/Rdynload.h>
56    #include <R_ext/Visibility.h>
57  #include "randtoolbox.h"  #include "randtoolbox.h"
58  #include "runifInterface.h"  #include "runifInterface.h"
59    #include "mt19937ar.h"
60  #include "testrng.h"  #include "testrng.h"
61    #include "version.h"
62    
63  //table of registration  //table of registration routines accessed with .C()
64    static const R_CMethodDef cMethods[] = {
65      {"set_noop", (DL_FUNC) &set_noop, 0}, //runifInterface.h
66      {"current_generator", (DL_FUNC) &current_generator, 1},
67      {"put_user_unif_set_generator", (DL_FUNC) &put_user_unif_set_generator, 0},
68      {"get_state_congru", (DL_FUNC) &get_state_congru, 2}, //congruRand.h
69      {"put_state_congru", (DL_FUNC) &put_state_congru, 3},
70      {"initMersenneTwister", (DL_FUNC) &initMersenneTwister, 4}, //mt19937ar.h
71      {"putMersenneTwister", (DL_FUNC) &putMersenneTwister, 3},
72      {"getMersenneTwister", (DL_FUNC) &getMersenneTwister, 3},
73      {"get_primes", (DL_FUNC) &get_primes, 2}, //randtoolbox.h
74      {"version_randtoolbox", (DL_FUNC) &version_randtoolbox, 1}, //version.h
75      {NULL, NULL, 0}
76    };
77    
78    
79    //table of registration routines accessed with .Call()
80  static const R_CallMethodDef callMethods[] =  static const R_CallMethodDef callMethods[] =
81  {  {
82          {"doTorus", (DL_FUNC) &doTorus, 6},          {"doTorus", (DL_FUNC) &doTorus, 7}, //randtoolbox.h
83            {"doHalton", (DL_FUNC) &doHalton, 6},
84            {"doSobol", (DL_FUNC) &doSobol, 6},
85          {"doSetSeed", (DL_FUNC) &doSetSeed, 1},          {"doSetSeed", (DL_FUNC) &doSetSeed, 1},
86          {"doCongruRand", (DL_FUNC) &doCongruRand, 6},          {"doCongruRand", (DL_FUNC) &doCongruRand, 6},
87          {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4},          {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4},
         {"doPokerTest", (DL_FUNC) &doPokerTest, 3},  
         {"doCollisionTest", (DL_FUNC) &doCollisionTest, 3},  
88          {"doWELL", (DL_FUNC) &doWELL, 5},          {"doWELL", (DL_FUNC) &doWELL, 5},
89          {"doKnuthTAOCP", (DL_FUNC) &doKnuthTAOCP, 2},          {"doKnuthTAOCP", (DL_FUNC) &doKnuthTAOCP, 2},
90            {"doPokerTest", (DL_FUNC) &doPokerTest, 3}, //testrng.h
91            {"doCollisionTest", (DL_FUNC) &doCollisionTest, 3},
92          {NULL, NULL, 0}          {NULL, NULL, 0}
93  };  };
94    
95    /* DOES NOT WORK => dynamic search
96    //table of registration routines accessed with .Fortran()
97    static const R_FortranMethodDef FortEntries[] = {
98      {"halton", (DL_FUNC) &F77_NAME(halton),  7},
99      {"sobol", (DL_FUNC) &F77_NAME(sobol),  11},
100      {NULL, NULL, 0}
101    };*/
102    
103    
104  //table of registered routines  //there is no routine accessed with .External()
105  void R_init_randtoolbox(DllInfo *info)  
106    //table of all registered routines
107    void R_init_randtoolbox(DllInfo *dll)
108  {  {
109          //register method accessed with .Call    //register method accessed with .C, .Call, .Fortran, .External respectively
110          R_registerRoutines(info, NULL, callMethods, NULL, NULL);    R_registerRoutines(dll, cMethods, callMethods, NULL, NULL);
111      R_useDynamicSymbols(dll, TRUE);
112    
113          //make randtoolbox C functions available from other packages    //make randtoolbox C functions available for other packages
114          R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);          R_RegisterCCallable("randtoolbox", "torus", (DL_FUNC) torus);
115      R_RegisterCCallable("randtoolbox", "halton", (DL_FUNC) halton);
116      R_RegisterCCallable("randtoolbox", "sobol", (DL_FUNC) halton);
117          R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);          R_RegisterCCallable("randtoolbox", "setSeed", (DL_FUNC) setSeed);
118          R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);          R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);
119          R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);          R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);
# Line 90  Line 124 
124                  //retrieve WELL rng entry point in the rngWELL pkg                  //retrieve WELL rng entry point in the rngWELL pkg
125                  WELLrng = (void (*) (double *, int, int, int, int, int)) R_GetCCallable("rngWELL", "WELLrng");                  WELLrng = (void (*) (double *, int, int, int, int, int)) R_GetCCallable("rngWELL", "WELLrng");
126                  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");
127      /*getRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "getRngWELL");
128       putRngWELL = (void (*) (int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "putRngWELL");
129       initMT2002 = (void (*) (unsigned int *, int *, unsigned int *)) R_GetCCallable("rngWELL", "initMT2002");*/
130    
131  }  }
132    

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

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