changeset 18813:bc52657a7d29

Convert isscalar from an m-file to a built-in function (bug #42422). * libinterp/corefcn/data.cc: add isscalar built-in function * scripts/general/isscalar.m: delete file * scripts/general/module.mk: remove isscalar.m from build system * doc/interpreter/contributors.in: Add Jason Alan Palmer to list.
author Jason Alan Palmer <jalanpalmer@gmail.com>
date Sun, 08 Jun 2014 18:43:36 -0400
parents 9ac2357f19bc
children 4f0e4f20a33f
files doc/interpreter/contributors.in libinterp/corefcn/data.cc scripts/general/isscalar.m scripts/general/module.mk
diffstat 4 files changed, 37 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/contributors.in	Sun Jun 08 17:59:59 2014 -0700
+++ b/doc/interpreter/contributors.in	Sun Jun 08 18:43:36 2014 -0400
@@ -224,6 +224,7 @@
 Carl Osterwisch
 Janne Olavi Paanajärvi
 Scott Pakin
+Jason Alan Palmer
 Gabriele Pannocchia
 Sylvain Pelissier
 Per Persson
--- a/libinterp/corefcn/data.cc	Sun Jun 08 17:59:59 2014 -0700
+++ 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\
--- a/scripts/general/isscalar.m	Sun Jun 08 17:59:59 2014 -0700
+++ /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
-## <http://www.gnu.org/licenses/>.
-
-## -*- 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)
-
--- a/scripts/general/module.mk	Sun Jun 08 17:59:59 2014 -0700
+++ 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 \