More conversions to logical values

trustregion
Sébastien Villemot 2022-03-23 16:49:05 +01:00
parent 79df767314
commit bef8d80ba8
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 16 additions and 16 deletions

View File

@ -12,7 +12,7 @@ function perfect_foresight_solver()
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 1996-2020 Dynare Team
% Copyright (C) 1996-2022 Dynare Team
%
% This file is part of Dynare.
%
@ -155,7 +155,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
% Solve for the paths of the endogenous variables.
[oo_,me] = perfect_foresight_solver_core(M_,options_,oo_);
if oo_.deterministic_simulation.status == 1
if oo_.deterministic_simulation.status
current_weight = new_weight;
if current_weight >= 1
if ~options_.noprint
@ -210,15 +210,15 @@ if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_fores
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
if max(abs(residuals))< options_.dynatol.f
oo_.deterministic_simulation.status = 1;
oo_.deterministic_simulation.status = true;
oo_.endo_simul=real(oo_.endo_simul);
else
oo_.deterministic_simulation.status = 0;
oo_.deterministic_simulation.status = false;
disp('Simulation terminated with imaginary parts in the residuals or endogenous variables.')
end
end
if oo_.deterministic_simulation.status == 1
if oo_.deterministic_simulation.status
if ~options_.noprint
fprintf('Perfect foresight solution found.\n\n')
end
@ -247,4 +247,4 @@ assignin('base', 'Simulated_time_series', ts);
if oo_.deterministic_simulation.status
oo_.gui.ran_perfect_foresight = true;
end
end

View File

@ -41,7 +41,7 @@ end
y=oo_.endo_simul;
T=NaN(M_.block_structure.dyn_tmp_nbr, options_.periods+M_.maximum_lag+M_.maximum_lead);
oo_.deterministic_simulation.status = 0;
oo_.deterministic_simulation.status = false;
funcname = [ M_.fname '.dynamic'];

View File

@ -88,10 +88,10 @@ else
end
for it_=start:incr:finish
cvg=0;
cvg=false;
iter=0;
g1=spalloc( Blck_size, Blck_size, nze);
while ~(cvg==1 || iter>maxit_)
while ~(cvg || iter>maxit_)
if is_dynamic
[r, yy, T(:, it_), g1] = feval(fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false);
y(:, it_) = yy(M.lead_lag_incidence(M.maximum_endo_lag+1,:));
@ -112,9 +112,9 @@ for it_=start:incr:finish
end
end
if ~isreal(max_res) || isnan(max_res)
cvg = 0;
cvg = false;
elseif is_linear && iter>0
cvg = 1;
cvg = true;
else
cvg=(max_res<solve_tolf);
end
@ -290,7 +290,7 @@ for it_=start:incr:finish
max_resa = max_res;
end
end
if cvg==0
if ~cvg
if verbose
if cutoff == 0
fprintf('Error in simul: Convergence not achieved in block %d, at time %d, after %d iterations.\n Increase "options_.simul.maxit\".\n',Block_Num, it_,iter);

View File

@ -66,7 +66,7 @@ function [y, T, oo]= solve_two_boundaries(fname, y, x, params, steady_state, T,
verbose = options.verbosity;
cvg=0;
cvg=false;
iter=0;
Per_u_=0;
Blck_size=size(y_index,2);
@ -79,7 +79,7 @@ ilu_setup.thresh = 1;
ilu_setup.udiag = 0;
max_resa=1e100;
reduced = 0;
while ~(cvg==1 || iter>maxit_)
while ~(cvg || iter>maxit_)
r = NaN(Blck_size, periods);
g1a = spalloc(Blck_size*periods, Blck_size*periods, nze*periods);
for it_ = y_kmin+(1:periods)
@ -104,9 +104,9 @@ while ~(cvg==1 || iter>maxit_)
max_res = (-max_res^2)^0.5;
end
if ~isreal(max_res) || isnan(max_res)
cvg = 0;
cvg = false;
elseif is_linear && iter>0
cvg = 1;
cvg = true;
else
cvg=(max_res<solve_tolf);
end