Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Johannes Pfeifer
dynare
Commits
762e7036
Commit
762e7036
authored
May 25, 2010
by
Houtan Bastani
Browse files
Allow the user to pass a constant seed
parent
478cfee0
Changes
9
Hide whitespace changes
Inline
Side-by-side
matlab/swz/c-code/mex/modify_for_mex.c
View file @
762e7036
...
...
@@ -9,6 +9,7 @@
#include
<dynmex.h>
#endif
int
constant_seed
;
int
swz_fprintf_stdout
(
char
*
msg
,
...)
{
...
...
matlab/swz/c-code/mex/modify_for_mex.h
View file @
762e7036
...
...
@@ -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
...
...
matlab/swz/c-code/sbvar/var/PrintDraws.c
View file @
762e7036
...
...
@@ -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
);
...
...
matlab/swz/c-code/sbvar/var/estimate.c
View file @
762e7036
...
...
@@ -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
);
...
...
matlab/swz/c-code/sbvar/var/mhm_VAR_main_1.c
View file @
762e7036
...
...
@@ -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*/
...
...
matlab/swz/c-code/sbvar/var/mhm_VAR_main_2.c
View file @
762e7036
...
...
@@ -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
(
"
\n
Syntax: marginal_VAR -d <number posterior draws>"
...
...
matlab/swz/c-code/utilities/DWCcode/stat/dw_rand.c
View file @
762e7036
...
...
@@ -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
--
)
...
...
matlab/swz/c-code/utilities/TZCcode/csminwel.c
View file @
762e7036
...
...
@@ -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
;
...
...
mex/sources/dynlapack.h
View file @
762e7036
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment