Skip to content
Snippets Groups Projects
Commit db62e3d7 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

issquare exists under Octave and returns the matrix dim if it is square

parent 2e65a9ab
No related branches found
No related tags found
No related merge requests found
......@@ -66,8 +66,9 @@ addpath([dynareroot '/utilities/general/'])
% or some MATLAB versions, and for which we provide some replacement functions
if ~exist('OCTAVE_VERSION')
% Replacements for rows() and columns() (inexistent under MATLAB)
% Replacements for rows(), columns() and issquare() (inexistent under MATLAB)
addpath([dynareroot '/missing/rows_columns'])
addpath([dynareroot '/missing/issquare'])
% Replacement for vec() (inexistent under MATLAB)
addpath([dynareroot '/missing/vec'])
if ~user_has_matlab_license('statistics_toolbox')
......
......@@ -4,7 +4,7 @@ function i = issquare(A)
%! @deftypefn {Function File} {@var{i} =} issquare (@var{A})
%! @anchor{issquare}
%! @sp 1
%! Returns 1 if @var{A} is a square matrix, 0 otherwise.
%! If @var{A} is a square matrix, returns its dimension; otherwise return 0.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
......@@ -17,7 +17,7 @@ function i = issquare(A)
%! @sp 1
%! @table @ @var
%! @item i
%! Integer scalar (0 or 1).
%! Integer scalar.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
......@@ -45,4 +45,8 @@ function i = issquare(A)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
d = size(A);
i = (length(d)==2) && (d(1)==d(2));
\ No newline at end of file
if (length(d)==2) && (d(1)==d(2))
i = d(1);
else
i = 0;
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment