From 1a1a4367a42eb1f2b1b9a4bd66c1bc7d220fef4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Tue, 13 Nov 2018 16:59:27 +0100 Subject: [PATCH] Add missing iscolumn and ismatrix for MATLAB < R2010b Also fix a bug in isrow (it was not checking the rank of the array). (cherry picked from commit ce49cd95df4b4f1d825b4c9d8a01ccf5945547c8) --- matlab/dynare_config.m | 4 ++-- .../missing/is-row-column-matrix/iscolumn.m | 20 +++++++++++++++++++ .../missing/is-row-column-matrix/ismatrix.m | 19 ++++++++++++++++++ .../{isrow => is-row-column-matrix}/isrow.m | 4 ++-- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 matlab/missing/is-row-column-matrix/iscolumn.m create mode 100644 matlab/missing/is-row-column-matrix/ismatrix.m rename matlab/missing/{isrow => is-row-column-matrix}/isrow.m (93%) diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index 0b36a161a5..9be0d84583 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -129,9 +129,9 @@ if ~isoctave && matlab_ver_less_than('8.1') p{end+1} = '/missing/strsplit'; end -% isrow is missing in Matlab<R2010b +% isrow, iscolumn and ismatrix are missing in Matlab<R2010b if ~isoctave && matlab_ver_less_than('7.11') - p{end+1} = '/missing/isrow'; + p{end+1} = '/missing/is-row-column-matrix'; end P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false); diff --git a/matlab/missing/is-row-column-matrix/iscolumn.m b/matlab/missing/is-row-column-matrix/iscolumn.m new file mode 100644 index 0000000000..0264efe198 --- /dev/null +++ b/matlab/missing/is-row-column-matrix/iscolumn.m @@ -0,0 +1,20 @@ +function r = iscolumn(V) +% Copyright (C) 2018 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/>. + +sz = size(V); +r = (length(sz) == 2) && (sz(2) == 1); diff --git a/matlab/missing/is-row-column-matrix/ismatrix.m b/matlab/missing/is-row-column-matrix/ismatrix.m new file mode 100644 index 0000000000..e9ed4ef2db --- /dev/null +++ b/matlab/missing/is-row-column-matrix/ismatrix.m @@ -0,0 +1,19 @@ +function r = ismatrix(V) +% Copyright (C) 2018 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/>. + +r = (ndims(V) == 2); diff --git a/matlab/missing/isrow/isrow.m b/matlab/missing/is-row-column-matrix/isrow.m similarity index 93% rename from matlab/missing/isrow/isrow.m rename to matlab/missing/is-row-column-matrix/isrow.m index 31eabdbe67..ef53534ede 100644 --- a/matlab/missing/isrow/isrow.m +++ b/matlab/missing/is-row-column-matrix/isrow.m @@ -16,5 +16,5 @@ function r = isrow(V) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -[m, n] = size(V); -r = (m == 1); +sz = size(V); +r = (length(sz) == 2) && (sz(1) == 1); -- GitLab