# HG changeset patch # User Rik # Date 1298961341 28800 # Node ID bea828c03969d40c3f87a673774e429a2288e019 # Parent bac54daffde2907739e5bd005e1f98e3677c5c1f Add new isrow, iscolumn functions. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-02-28 Rik + + * NEWS: Mention new functions isrow, iscolumn. + 2011-02-23 Jordi GutiƩrrez Hermoso * .hgignore: Cleanup and more files to be ignore that get added diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ Summary of important user-visible changes for version 3.6: --------------------------------------------------------- + ** The PCRE library is now required to build Octave. + + ** New functions added. + iscolumn + issrow + ** Deprecated functions. The following functions were deprecated in Octave 3.2 and have been @@ -18,8 +24,6 @@ spchol splchol unmark_command spchol2inv split unmark_rawcommand - ** The PCRE library is now required to build Octave. - Summary of important user-visible changes for version 3.4: --------------------------------------------------------- diff --git a/doc/ChangeLog b/doc/ChangeLog --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2010-02-28 Rik + + * interpreter/numbers.txi: Add isrow, iscolumn functions to manual. + 2011-02-25 Jordi GutiƩrrez Hermoso * faq/OctaveFAQ.texi: Uniformise all mentions of Matlab to be diff --git a/doc/interpreter/numbers.txi b/doc/interpreter/numbers.txi --- a/doc/interpreter/numbers.txi +++ b/doc/interpreter/numbers.txi @@ -819,6 +819,10 @@ @DOCSTRING(isvector) +@DOCSTRING(isrow) + +@DOCSTRING(iscolumn) + @DOCSTRING(isscalar) @DOCSTRING(issquare) diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-02-28 Rik + + * general/iscolumn.m, general/isrow.m: Add 2 new utility functions + to check for row or column vector. + 2010-02-28 Rik * sparse/treeplot.m: Use 'o' plot style as default for nodes diff --git a/scripts/general/iscolumn.m b/scripts/general/iscolumn.m new file mode 100644 --- /dev/null +++ b/scripts/general/iscolumn.m @@ -0,0 +1,62 @@ +## Copyright (C) 2011 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} iscolumn (@var{x}) +## Return true if @var{x} is a column vector. +## @seealso{isrow, isscalar, isvector, ismatrix} +## @end deftypefn + +## Author: Rik Wehbring + +function retval = iscolumn (x) + + retval = false; + + if (nargin != 1) + print_usage (); + endif + + sz = size (x); + retval = (ndims (x) == 2 && (sz(2) == 1)); + +endfunction + +%!assert(iscolumn ([1, 2, 3]), false); +%!assert(iscolumn ([1; 2; 3])); +%!assert(iscolumn (1)); +%!assert(iscolumn ([]), false); +%!assert(iscolumn ([1, 2; 3, 4]), false); + +%!test +%! warning ("off", "Octave:str-to-num"); +%! assert((iscolumn ("t"))); +%!test +%! warning ("off", "Octave:str-to-num"); +%! assert(!(iscolumn ("test"))); + +%!assert(!(iscolumn (["test"; "ing"]))); + +%!test +%! s.a = 1; +%! assert((iscolumn (s))); + +%% Test input validation +%!error iscolumn (); +%!error iscolumn ([1, 2], 2); + diff --git a/scripts/general/isrow.m b/scripts/general/isrow.m new file mode 100644 --- /dev/null +++ b/scripts/general/isrow.m @@ -0,0 +1,62 @@ +## Copyright (C) 2011 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} isrow (@var{x}) +## Return true if @var{x} is a row vector. +## @seealso{iscolumn, isscalar, isvector, ismatrix} +## @end deftypefn + +## Author: Rik Wehbring + +function retval = isrow (x) + + retval = false; + + if (nargin != 1) + print_usage (); + endif + + sz = size (x); + retval = (ndims (x) == 2 && (sz(1) == 1)); + +endfunction + +%!assert(isrow ([1, 2, 3])); +%!assert(isrow ([1; 2; 3]), false); +%!assert(isrow (1)); +%!assert(isrow ([]), false); +%!assert(isrow ([1, 2; 3, 4]), false); + +%!test +%! warning ("off", "Octave:str-to-num"); +%! assert((isrow ("t"))); +%!test +%! warning ("off", "Octave:str-to-num"); +%! assert((isrow ("test"))); + +%!assert(!(isrow (["test"; "ing"]))); + +%!test +%! s.a = 1; +%! assert((isrow (s))); + +%% Test input validation +%!error isrow (); +%!error isrow ([1, 2], 2); + diff --git a/scripts/general/module.mk b/scripts/general/module.mk --- a/scripts/general/module.mk +++ b/scripts/general/module.mk @@ -44,9 +44,11 @@ general/interpft.m \ general/is_duplicate_entry.m \ general/isa.m \ + general/iscolumn.m \ general/isdir.m \ general/isequal.m \ general/isequalwithequalnans.m \ + general/isrow.m \ general/isscalar.m \ general/issquare.m \ general/isvector.m \