Commit 04469ddc authored by Ferhat Mihoubi's avatar Ferhat Mihoubi
Browse files

- Add variable input arguments

- Correct the error condition in A_times_B_kronecker_C
parent 032957b3
......@@ -35,9 +35,11 @@ function [err, D] = A_times_B_kronecker_C(A,B,C,fake)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% 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);
......
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 <http://www.gnu.org/licenses/>.
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment