diff --git a/matlab/kronecker/A_times_B_kronecker_C.m b/matlab/kronecker/A_times_B_kronecker_C.m index a810326a5..c70c2e86a 100644 --- a/matlab/kronecker/A_times_B_kronecker_C.m +++ b/matlab/kronecker/A_times_B_kronecker_C.m @@ -35,9 +35,11 @@ function [err, D] = A_times_B_kronecker_C(A,B,C,fake) % along with Dynare. If not, see . % Chek number of inputs and outputs. -if nargin>3 || nargin<2 || nargout~=2 +if nargin>4 || nargin<3 || nargout~=2 error('A_times_B_kronecker_C takes 3 or 4 input arguments and provides exactly 2 output arguments.') end + + % Get & check dimensions. Initialization of the output matrix. [mA,nA] = size(A); [mB,nB] = size(B); diff --git a/matlab/kronecker/sparse_hessian_times_B_kronecker_C.m b/matlab/kronecker/sparse_hessian_times_B_kronecker_C.m index 5273c1078..028ea9244 100644 --- a/matlab/kronecker/sparse_hessian_times_B_kronecker_C.m +++ b/matlab/kronecker/sparse_hessian_times_B_kronecker_C.m @@ -1,5 +1,5 @@ -function [err, D] = sparse_hessian_times_B_kronecker_C(A,B,C,fake) -%function [err, D] = sparse_hessian_times_B_kronecker_C(A,B,C) +function [err, D] = sparse_hessian_times_B_kronecker_C(varargin) +%function [err, D] = sparse_hessian_times_B_kronecker_C(A,B,C, fake) % Computes A * kron(B,C) where A is a sparse matrix. % % INPUTS @@ -33,16 +33,19 @@ function [err, D] = sparse_hessian_times_B_kronecker_C(A,B,C,fake) % % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . - +A = varargin{1}; +B = varargin{2}; +C = varargin{3}; +fake = varargin{nargin}; if nargout~=2 error('sparse_hessian_times_B_kronecker_C provides exactly 2 output arguments.') end switch nargin case 4 - D = A_times_B_kronecker_C(A,B,C,fake); + [fake,D] = A_times_B_kronecker_C(A,B,C,fake); case 3 - D = A_times_B_kronecker_C(A,B,B,fake); + [fake,D] = A_times_B_kronecker_C(A,B,C); otherwise error('Two or Three input arguments required!') end