From d32e076b77e4e8ad01d88b94b71a7c1a5763d7cd Mon Sep 17 00:00:00 2001 From: Michel Juillard <michel.juillard@mjui.fr> Date: Sun, 22 Jul 2012 22:18:32 +0200 Subject: [PATCH] adding missing function linsolve for Octave (inefficient and minimal implementation for current needs) --- matlab/dynare_config.m | 5 +++++ matlab/missing/linsolve/linsolve.m | 33 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 matlab/missing/linsolve/linsolve.m diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index 98ed0c0bbe..0644f8e7f7 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 0000000000..2ae167bd44 --- /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 <http://www.gnu.org/licenses/>. + + c = []; + x = []; + if nargin == 3 + if isfield(opts,'TRANSA') + A = A'; + end + end + if nargout == 2 + c = rcond(A); + end + + x = A\B; + -- GitLab