# HG changeset patch # User Olaf Till # Date 1372700991 -7200 # Node ID dd783018709b626611c6359c46166261a0d0cad6 # Parent 234519448e7614961c2bc759134b1acf4cf3e03f Add special case function "isnumeric" to cellfun.cc (bug #39387). diff -r 234519448e76 -r dd783018709b libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Mon Jul 01 19:29:10 2013 +0200 +++ b/libinterp/corefcn/cellfun.cc Mon Jul 01 19:49:51 2013 +0200 @@ -133,6 +133,13 @@ result(count) = f_args.elem (count).is_bool_type (); retval(0) = result; } + else if (name == "isnumeric") + { + boolNDArray result (f_args.dims ()); + for (octave_idx_type count= 0; count < k; count++) + result(count) = f_args.elem (count).is_numeric_type (); + retval(0) = result; + } else if (name == "isreal") { boolNDArray result (f_args.dims ()); @@ -278,6 +285,9 @@ @item islogical\n\ Return 1 for logical elements.\n\ \n\ +@item isnumeric\n\ +Return 1 for numeric elements.\n\ +\n\ @item isreal\n\ Return 1 for real elements.\n\ \n\ @@ -778,7 +788,7 @@ %! assert (A, [true, false, true, false]); %% First input argument can be the special string "isreal", -%% "isempty", "islogical", "length", "ndims" or "prodofsize" +%% "isempty", "islogical", "isnumeric", "length", "ndims" or "prodofsize" %!test %! A = cellfun ("isreal", {true, 0.1, {}, i*2, [], "abc"}); %! assert (A, [true, true, false, false, true, true]); @@ -789,6 +799,9 @@ %! A = cellfun ("islogical", {true, 0.1, false, i*2, [], "abc"}); %! assert (A, [true, false, true, false, false, false]); %!test +%! A = cellfun ("isnumeric", {true, 0.1, false, i*2, [], "abc"}); +%! assert (A, [false, true, false, true, true, false]); +%!test %! A = cellfun ("length", {true, 0.1, false, i*2, [], "abc"}); %! assert (A, [1, 1, 1, 1, 0, 3]); %!test @@ -989,6 +1002,7 @@ %!assert (cellfun ("sin", {0,1}), sin ([0,1])) %!assert (cellfun ("isempty", {1,[]}), [false,true]) %!assert (cellfun ("islogical", {false,pi}), [true,false]) +%!assert (cellfun ("isnumeric", {false,pi,struct()}), [false,true,false]) %!assert (cellfun ("isreal", {1i,1}), [false,true]) %!assert (cellfun ("length", {zeros(2,2),1}), [2,1]) %!assert (cellfun ("prodofsize", {zeros(2,2),1}), [4,1])