isdiag was introduced in MATLAB R2014a
Provide a replacement by reusing a similar function that was under matlab/general/utilities/.time-shift
parent
37d7dc65ae
commit
04323301a5
|
@ -132,6 +132,11 @@ if ~isoctave && matlab_ver_less_than('7.11')
|
|||
p{end+1} = '/missing/is-row-column-matrix';
|
||||
end
|
||||
|
||||
%% isdiag is missing in MATLAB < R2014a
|
||||
if ~isoctave && matlab_ver_less_than('8.4')
|
||||
p{end+1} = '/missing/isdiag';
|
||||
end
|
||||
|
||||
P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false);
|
||||
|
||||
% Get mex files folder(s)
|
||||
|
|
|
@ -180,7 +180,7 @@ if options_.loglinear && isfield(oo_.dr,'ys') && options_.logged_steady_state==0
|
|||
options_.logged_steady_state=1; %set option for use in stoch_simul
|
||||
end
|
||||
|
||||
if ~isdiagonal(M_.Sigma_e)
|
||||
if ~isdiag(M_.Sigma_e)
|
||||
warning(sprintf('The innovations are correlated (the covariance matrix has non zero off diagonal elements), the results of the conditional forecasts will\ndepend on the ordering of the innovations (as declared after varexo) because a Cholesky decomposition is used to factorize the covariance matrix.\n\n=> It is preferable to declare the correlations in the model block (explicitly imposing the identification restrictions), unless you are satisfied\nwith the implicit identification restrictions implied by the Cholesky decomposition.'))
|
||||
sQ = chol(M_.Sigma_e,'lower');
|
||||
else
|
||||
|
@ -299,4 +299,4 @@ forecasts.graph.fname = M_.fname;
|
|||
%reset qz_criterium
|
||||
options_.qz_criterium=qz_criterium_old;
|
||||
|
||||
save('conditional_forecasts.mat','forecasts');
|
||||
save('conditional_forecasts.mat','forecasts');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function b = isdiagonal(A) % --*-- Unitary tests --*--
|
||||
function b = isdiag(A) % --*-- Unitary tests --*--
|
||||
|
||||
% Copyright (C) 2014-2017 Dynare Team
|
||||
%
|
||||
|
@ -25,38 +25,38 @@ if isnumeric(A)
|
|||
% in ir and ic (row and column numbers) should be equal.
|
||||
b = isequal(ir, ic);
|
||||
else
|
||||
error('isdiagonal: Input must be a square matrix!')
|
||||
error('isdiag: Input must be a square matrix!')
|
||||
end
|
||||
else
|
||||
error('isdiagonal: Input must be numeric!')
|
||||
error('isdiag: Input must be numeric!')
|
||||
end
|
||||
|
||||
%@test:1
|
||||
%$ A = zeros(3,3);
|
||||
%$ t = isdiagonal(A);
|
||||
%$ t = isdiag(A);
|
||||
%$ T = all(t);
|
||||
%@eof:1
|
||||
|
||||
%@test:2
|
||||
%$ A = zeros(3,3); A(1,3) = 1;
|
||||
%$ t = ~isdiagonal(A);
|
||||
%$ t = ~isdiag(A);
|
||||
%$ T = all(t);
|
||||
%@eof:2
|
||||
|
||||
%@test:3
|
||||
%$ A = randn(3,3);
|
||||
%$ t = ~isdiagonal(A);
|
||||
%$ t = ~isdiag(A);
|
||||
%$ T = all(t);
|
||||
%@eof:3
|
||||
|
||||
%@test:4
|
||||
%$ A = diag(randn(3,1));
|
||||
%$ t = isdiagonal(A);
|
||||
%$ t = isdiag(A);
|
||||
%$ T = all(t);
|
||||
%@eof:4
|
||||
|
||||
%@test:5
|
||||
%$ A = diag(randn(3,1)); A(1,1) = 0;
|
||||
%$ t = isdiagonal(A);
|
||||
%$ t = isdiag(A);
|
||||
%$ T = all(t);
|
||||
%@eof:5
|
Loading…
Reference in New Issue