diff --git a/matlab/moment_function.m b/matlab/moment_function.m index 6dcc21d81..428f8f180 100644 --- a/matlab/moment_function.m +++ b/matlab/moment_function.m @@ -15,7 +15,7 @@ function [g,flag] = moment_function(xparams,sample_moments,dataset,options,paral % SPECIAL REQUIREMENTS % The user has to provide a file where the moment conditions are defined. -% Copyright (C) 2010 Dynare Team +% Copyright (C) 2010-2012 Dynare Team % % This file is part of Dynare. % @@ -40,7 +40,11 @@ flag = 1; if nargin<5 if isempty(mainStream) - mainStream = RandStream.getDefaultStream; + if matlab_ver_less_than('7.12') + mainStream = RandStream.getDefaultStream; + else + mainStream = RandStream.getGlobalStream; + end mainState = mainStream.State; else mainStream.State = mainState; diff --git a/matlab/set_dynare_seed.m b/matlab/set_dynare_seed.m index a10531fa5..944d11e50 100644 --- a/matlab/set_dynare_seed.m +++ b/matlab/set_dynare_seed.m @@ -2,7 +2,7 @@ function set_dynare_seed(a,b) % Set seeds depending on matlab (octave) version. This routine is called in dynare_config and can be called by the % user in the mod file. % -% Copyright (C) 2010-2011 Dynare Team +% Copyright (C) 2010-2012 Dynare Team % % This file is part of Dynare. % @@ -32,12 +32,20 @@ if matlab_random_streams% Use new matlab interface. options_.DynareRandomStreams.algo = 'mt19937ar'; options_.DynareRandomStreams.seed = 0; s = RandStream(options_.DynareRandomStreams.algo,'Seed',options_.DynareRandomStreams.seed); - reset(RandStream.setDefaultStream(s)); + if matlab_ver_less_than('7.12') + reset(RandStream.setDefaultStream(s)); + else + reset(RandStream.setGlobalStream(s)); + end return end if ischar(a) && strcmpi(a,'reset') s = RandStream(options_.DynareRandomStreams.algo,'Seed',options_.DynareRandomStreams.seed); - reset(RandStream.setDefaultStream(s)); + if matlab_ver_less_than('7.12') + reset(RandStream.setDefaultStream(s)); + else + reset(RandStream.setGlobalStream(s)); + end return end if ischar(a) @@ -47,7 +55,11 @@ if matlab_random_streams% Use new matlab interface. options_.DynareRandomStreams.algo = 'mt19937ar'; options_.DynareRandomStreams.seed = a; s = RandStream(options_.DynareRandomStreams.algo,'Seed',options_.DynareRandomStreams.seed); - reset(RandStream.setDefaultStream(s)); + if matlab_ver_less_than('7.12') + reset(RandStream.setDefaultStream(s)); + else + reset(RandStream.setGlobalStream(s)); + end return end elseif nargin==2 @@ -70,7 +82,11 @@ if matlab_random_streams% Use new matlab interface. options_.DynareRandomStreams.algo = a; options_.DynareRandomStreams.seed = b; s = RandStream(options_.DynareRandomStreams.algo,'Seed',options_.DynareRandomStreams.seed); - reset(RandStream.setDefaultStream(s)); + if matlab_ver_less_than('7.12') + reset(RandStream.setDefaultStream(s)); + else + reset(RandStream.setGlobalStream(s)); + end end else% Use old matlab interface. if nargin==1 diff --git a/matlab/simulated_moments_estimation.m b/matlab/simulated_moments_estimation.m index 141ce3a2e..74b30f78a 100644 --- a/matlab/simulated_moments_estimation.m +++ b/matlab/simulated_moments_estimation.m @@ -14,7 +14,7 @@ function [param,sigma] = simulated_moments_estimation(dataset,options,parallel) % SPECIAL REQUIREMENTS % The user has to provide a file where the moment conditions are defined. -% Copyright (C) 2010-2011 Dynare Team +% Copyright (C) 2010-2012 Dynare Team % % This file is part of Dynare. % @@ -269,7 +269,11 @@ fprintf(fid,['tmp([' num2str(variance_idx) ']) = xparams(1:' int2str(nv) ').^2; fprintf(fid,'M_.Sigma_e = diag(tmp);') fprintf(fid,['stream=RandStream(''mt19937ar'',''Seed'',' int2str(slave_number) ');\n']); -fprintf(fid,['RandStream.setDefaultStream(stream);\n\n']); +if matlab_ver_less_than('7.12') + fprintf(fid,['RandStream.setDefaultStream(stream);\n\n']); +else + fprintf(fid,['RandStream.setGlobalStream(stream);\n\n']); +end fprintf(fid,['maxNumCompThreads(' int2str(threads_per_job) ');\n\n']); diff --git a/matlab/smm_objective.m b/matlab/smm_objective.m index 5a0773b02..806746369 100644 --- a/matlab/smm_objective.m +++ b/matlab/smm_objective.m @@ -15,7 +15,7 @@ function [r,flag] = smm_objective(xparams,sample_moments,weighting_matrix,option % SPECIAL REQUIREMENTS % The user has to provide a file where the moment conditions are defined. -% Copyright (C) 2010 Dynare Team +% Copyright (C) 2010-2012 Dynare Team % % This file is part of Dynare. % @@ -40,7 +40,11 @@ flag = 1; if nargin<5 if isempty(mainStream) - mainStream = RandStream.getDefaultStream; + if matlab_ver_less_than('7.12') + mainStream = RandStream.getDefaultStream; + else + mainStream = RandStream.getGlobalStream; + end mainState = mainStream.State; else mainStream.State = mainState;