SCM

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6032 - (view) (download) (as text)

1 : dutangc 4229 /**
2 :     * @file init.c
3 :     * @brief init file for all RNGs
4 :     *
5 :     * @author Christophe Dutang
6 :     * @author Petr Savicky
7 :     *
8 :     *
9 : dutangc 6028 * Copyright (C) 2017, Christophe Dutang,
10 : dutangc 4229 * Petr Savicky, Academy of Sciences of the Czech Republic.
11 :     * All rights reserved.
12 :     *
13 :     * The new BSD License is applied to this software.
14 : dutangc 5471 * Copyright (c) 2013 Christophe Dutang, Petr Savicky.
15 : dutangc 4229 * All rights reserved.
16 :     *
17 :     * Redistribution and use in source and binary forms, with or without
18 :     * modification, are permitted provided that the following conditions are
19 :     * met:
20 :     *
21 :     * - Redistributions of source code must retain the above copyright
22 :     * notice, this list of conditions and the following disclaimer.
23 :     * - Redistributions in binary form must reproduce the above
24 :     * copyright notice, this list of conditions and the following
25 :     * disclaimer in the documentation and/or other materials provided
26 :     * with the distribution.
27 :     * - Neither the name of the Academy of Sciences of the Czech Republic
28 :     * nor the names of its contributors may be used to endorse or promote
29 :     * products derived from this software without specific prior written
30 :     * permission.
31 :     *
32 :     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 :     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 :     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35 :     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 :     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 :     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 :     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39 :     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
40 :     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 :     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
42 :     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 :     *
44 :     */
45 : dutangc 4236 /*****************************************************************************
46 : dutangc 4229 * randtoolbox to generate pseudo and quasi random sequences
47 : dutangc 3644 *
48 :     * init file
49 :     *
50 :     * Native routines registration, see 'writing R extensions'
51 :     *
52 :     */
53 :    
54 :     #include <Rinternals.h>
55 :     #include <R_ext/Rdynload.h>
56 : dutangc 6032 #include <R_ext/Visibility.h>
57 : dutangc 3644 #include "randtoolbox.h"
58 : savicky 4474 #include "runifInterface.h"
59 : dutangc 6032 #include "mt19937ar.h"
60 : dutangc 3644 #include "testrng.h"
61 : dutangc 6032 #include "version.h"
62 : dutangc 3644
63 : dutangc 6032 //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 : dutangc 3644 static const R_CallMethodDef callMethods[] =
81 :     {
82 : dutangc 6032 {"doTorus", (DL_FUNC) &doTorus, 7}, //randtoolbox.h
83 : dutangc 6028 {"doHalton", (DL_FUNC) &doHalton, 6},
84 :     {"doSobol", (DL_FUNC) &doSobol, 6},
85 : dutangc 3644 {"doSetSeed", (DL_FUNC) &doSetSeed, 1},
86 :     {"doCongruRand", (DL_FUNC) &doCongruRand, 6},
87 :     {"doSFMersenneTwister", (DL_FUNC) &doSFMersenneTwister, 4},
88 :     {"doWELL", (DL_FUNC) &doWELL, 5},
89 :     {"doKnuthTAOCP", (DL_FUNC) &doKnuthTAOCP, 2},
90 : dutangc 6032 {"doPokerTest", (DL_FUNC) &doPokerTest, 3}, //testrng.h
91 :     {"doCollisionTest", (DL_FUNC) &doCollisionTest, 3},
92 : dutangc 3644 {NULL, NULL, 0}
93 :     };
94 :    
95 : dutangc 6032 /* 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 : dutangc 4229
103 : dutangc 6032
104 :     //there is no routine accessed with .External()
105 :    
106 :     //table of all registered routines
107 :     void R_init_randtoolbox(DllInfo *dll)
108 : dutangc 3644 {
109 : dutangc 6032 //register method accessed with .C, .Call, .Fortran, .External respectively
110 :     R_registerRoutines(dll, cMethods, callMethods, NULL, NULL);
111 :     R_useDynamicSymbols(dll, TRUE);
112 : dutangc 6030
113 :     //make randtoolbox C functions available for other packages
114 :     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);
118 :     R_RegisterCCallable("randtoolbox", "congruRand", (DL_FUNC) congruRand);
119 :     R_RegisterCCallable("randtoolbox", "SFmersennetwister", (DL_FUNC) SFmersennetwister);
120 :     R_RegisterCCallable("randtoolbox", "pokerTest", (DL_FUNC) pokerTest);
121 :     R_RegisterCCallable("randtoolbox", "collisionTest", (DL_FUNC) collisionTest);
122 :     R_RegisterCCallable("randtoolbox", "knuthTAOCP", (DL_FUNC) knuthTAOCP);
123 :    
124 :     //retrieve WELL rng entry point in the rngWELL pkg
125 :     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");
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 : dutangc 3644 }
132 : dutangc 4229

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