# HG changeset patch # User Jason Alan Palmer # Date 1402267416 14400 # Sun Jun 08 18:43:36 2014 -0400 # Node ID 152571421cd4917cfab2e89614f8b663ef3ba982 # Parent f550c37a9e9cd00dcf2f67f8a1ccef190fa48d1d Convert isscalar from an m-file to a built-in function * libinterp/corefcn/data.cc: add isscalar built-in function * scripts/general/isscalar.m: delete file * scripts/general/module.mk: remove reference to deleted file diff -r f550c37a9e9c -r 152571421cd4 libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Fri Jun 06 09:43:54 2014 -0400 +++ b/libinterp/corefcn/data.cc Sun Jun 08 18:43:36 2014 -0400 @@ -3650,6 +3650,42 @@ %!assert (isnumeric (sparse ([true, false])), false) */ +DEFUN (isscalar, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} isscalar (@var{x})\n\ +Return true if @var{x} is a scalar.\n\ +@seealso{isvector, ismatrix}\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + retval = args(0).numel () == 1; + else + print_usage (); + + return retval; +} + +/* +%!assert (isscalar (1)) +%!assert (isscalar ([1, 2]), false) +%!assert (isscalar ([]), false) +%!assert (isscalar ([1, 2; 3, 4]), false) + +%!assert (isscalar ("t")) +%!assert (isscalar ("test"), false) +%!assert (isscalar (["test"; "ing"]), false) + +%!test +%! s.a = 1; +%! assert (isscalar (s)); + +%% Test input validation +%!error isscalar () +%!error isscalar (1, 2) +*/ + DEFUN (ismatrix, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} ismatrix (@var{a})\n\ diff -r f550c37a9e9c -r 152571421cd4 scripts/general/isscalar.m --- a/scripts/general/isscalar.m Fri Jun 06 09:43:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -## Copyright (C) 1996-2013 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} {} isscalar (@var{x}) -## Return true if @var{x} is a scalar. -## @seealso{isvector, ismatrix} -## @end deftypefn - -## Author: jwe - -function retval = isscalar (x) - - if (nargin != 1) - print_usage (); - endif - - retval = numel (x) == 1; - -endfunction - - -%!assert (isscalar (1)) -%!assert (isscalar ([1, 2]), false) -%!assert (isscalar ([]), false) -%!assert (isscalar ([1, 2; 3, 4]), false) - -%!assert (isscalar ("t")) -%!assert (isscalar ("test"), false) -%!assert (isscalar (["test"; "ing"]), false) - -%!test -%! s.a = 1; -%! assert (isscalar (s)); - -%% Test input validation -%!error isscalar () -%!error isscalar (1, 2) - diff -r f550c37a9e9c -r 152571421cd4 scripts/general/module.mk --- a/scripts/general/module.mk Fri Jun 06 09:43:54 2014 -0400 +++ b/scripts/general/module.mk Sun Jun 08 18:43:36 2014 -0400 @@ -44,7 +44,6 @@ general/isequal.m \ general/isequaln.m \ general/isrow.m \ - general/isscalar.m \ general/issquare.m \ general/isvector.m \ general/loadobj.m \