Commit 762e7036 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

Allow the user to pass a constant seed

parent 478cfee0
......@@ -9,6 +9,7 @@
#include <dynmex.h>
#endif
int constant_seed;
int
swz_fprintf_stdout(char *msg, ...)
{
......
......@@ -3,6 +3,7 @@
void swz_exit(int status);
void swz_fprintf_err(const char * str, ...);
int swz_fprintf_stdout(char *msg, ...);
extern int constant_seed;
#endif
......
......@@ -55,6 +55,7 @@ int main(int nargs, char **args)
}
/* //=== Get seed, tuning peroid, burn-in period, number of iterations, and thinning factor ansi-c*/
constant_seed=dw_ParseInteger_String(nargs,args,"cseed",0);
seed=dw_ParseInteger_String(nargs,args,"gs",0);
tuning=dw_ParseInteger_String(nargs,args,"mh",30000);
iterations=dw_ParseInteger_String(nargs,args,"i",1000);
......
......@@ -619,6 +619,8 @@ int main(int nargs, char **args)
return 0;
}
constant_seed=dw_ParseInteger_String(nargs,args,"cseed",0);
/* // Generator seed ansi-c*/
seed=dw_ParseInteger_String(nargs,args,"gs",0);
dw_initialize_generator(seed);
......
......@@ -347,6 +347,8 @@ int main(int nargs, char **args)
int initial_time, begin_time, end_time;
FILE *f_out_intermediate, *f_out_final, *f_out_intermediate_draws;
constant_seed=dw_ParseInteger_String(nargs,args,"cseed",0);
if (mhm=CreateMHM_CommandLine(nargs,args))
{
/* //=== Random seed ===// ansi-c*/
......
......@@ -1920,6 +1920,9 @@ int main(int nargs, char **args)
/* Read command line and input files */
/*****************************************************************************/
/* // help ansi-c*/
constant_seed=dw_ParseInteger_String(nargs,args,"cseed",0);
if (dw_FindArgument(nargs,args,'h') >= 0)
{
printf("\nSyntax: marginal_VAR -d <number posterior draws>"
......
......@@ -216,12 +216,18 @@ PRECISION dw_uniform_rnd(void)
if (idum <= 0)
{
if (idum == 0)
{
idum=abs((int)time((time_t *)NULL));
if (idum == 0) idum=1;
}
{
if(constant_seed==0)
idum=abs((int)time((time_t *)NULL));
else
{
srand(constant_seed);
idum=rand();
}
if (idum == 0) idum=1;
}
else
idum=-idum;
idum=-idum;
for (j=NTAB+7; j >= 0; j--)
{
......@@ -274,12 +280,18 @@ PRECISION dw_uniform_rnd(void)
if (idum <= 0)
{
if (idum == 0)
{
idum=abs((int)time((time_t *)NULL));
if (idum == 0) idum=1;
}
{
if(constant_seed==0)
idum=abs((int)time((time_t *)NULL));
else
{
srand(constant_seed);
idum=rand();
}
if (idum == 0) idum=1;
}
else
idum=-idum;
idum=-idum;
idum2=idum;
for (j=NTAB+7; j>=0; j--)
......
......@@ -134,9 +134,14 @@ void csminwel(double (*fcn)(double *x, int n, double **args, int *dims),
/* //=== Seed for random number generator in stdlib.h. Added by T.Zha; 03/10/2006. ansi-c*/
if (!RANDOMSEED_CSMINWEL)
randomseed = (unsigned int)time((time_t *)NULL);
/* //Note that (unsigned int)time(0) uses the time of day for random seed. ansi-c*/
/* //Added by T.Zha; 03/10/2006. time() is in time.h. ansi-c*/
{
if(constant_seed==0)
randomseed = (unsigned int)time((time_t *)NULL);
/* //Note that (unsigned int)time(0) uses the time of day for random seed. ansi-c*/
/* //Added by T.Zha; 03/10/2006. time() is in time.h. ansi-c*/
else
randomseed = constant_seed;
}
else
randomseed = (unsigned int)RANDOMSEED_CSMINWEL;
......
......@@ -60,7 +60,7 @@ extern "C" {
typedef lapack_int (*SGGESCRIT)(const float *, const float *, const float *);
typedef float *LAFLT;
typedef const float *CONST_LAFLT;
typedef lapack_int *CONST_LALOG; //logical
typedef lapack_int *CONST_LALOG; /*logical*/
#define dgetrs FORTRAN_WRAPPER(dgetrs)
void dgetrs(LACHAR trans, CONST_LAINT n, CONST_LAINT nrhs, CONST_LADOU a, CONST_LAINT lda, CONST_LAINT ipiv,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment