diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index 98ed0c0bb..0644f8e7f 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -93,6 +93,11 @@ if (exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('statistics')) ... addpath([dynareroot '/missing/nanmean']) end +% linsolve is missing in Octave +if (exist('OCTAVE_VERSION')) + addpath([dynareroot '/missing/linsolve']) +end + % Add path to MEX files if exist('OCTAVE_VERSION') addpath([dynareroot '../mex/octave/']); diff --git a/matlab/missing/linsolve/linsolve.m b/matlab/missing/linsolve/linsolve.m new file mode 100644 index 000000000..2ae167bd4 --- /dev/null +++ b/matlab/missing/linsolve/linsolve.m @@ -0,0 +1,33 @@ +function [x,c] = linsolve(A,B,opts) +% (very imperfect) Clone of Matlab's linsolve. + +% Copyright (C) 2010-2011 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + + c = []; + x = []; + if nargin == 3 + if isfield(opts,'TRANSA') + A = A'; + end + end + if nargout == 2 + c = rcond(A); + end + + x = A\B; +