Mercurial > hg > octave-lojdl
changeset 17430:1b93b2de3a8c
Merging with main repo after addind check method.
author | Andrej Lojdl <andrej.lojdl@gmail.com> |
---|---|
date | Wed, 11 Sep 2013 20:49:40 +0200 |
parents | 21f67db6ab1b (current diff) f47cfca56eb9 (diff) |
children | 71b6f8a81e80 |
files | scripts/plot/private/__color_str_rgb__.m |
diffstat | 37 files changed, 562 insertions(+), 490 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/mk_doc_cache.m +++ b/doc/interpreter/mk_doc_cache.m @@ -48,10 +48,22 @@ endif endif endfor -text = [text{:}, doc_delim]; +text = [text{:}]; + +## Strip Texinfo marker +text = regexprep (text, "-\\*- texinfo -\\*-[ \t]*[\r\n]*", ""); -## Strip Texinfo markers and docstring separators. -text = regexprep (text, "-\\*- texinfo -\\*-[ \t]*[\r\n]*", ""); +## Add keywords and operators +other_docstrings = [__keywords__; __operators__]; +for i = 1 : numel (other_docstrings) + name = other_docstrings{i}; + ## Special handling of block comment operators such as '#{' + esc_name = regexprep (name, '([{}])', '@$1'); + text = [text doc_delim esc_name get_help_text(name) "\n"]; +endfor +text(end+1) = doc_delim; + +## Double '@' symbol for Texinfo text = strrep (text, [doc_delim "@"], [doc_delim "@@"]); ## Write data to temporary file for input to makeinfo
--- a/libgui/src/dialog.cc +++ b/libgui/src/dialog.cc @@ -420,7 +420,7 @@ buttonCancel_clicked (); } -FileDialog::FileDialog (const QStringList& filters, const QString& title, +FileDialog::FileDialog (const QStringList& name_filters, const QString& title, const QString& filename, const QString& dirname, const QString& multimode) : QFileDialog() @@ -456,7 +456,7 @@ setAcceptMode (QFileDialog::AcceptOpen); } - setNameFilters (filters); + setNameFilters (name_filters); selectFile (filename); @@ -493,8 +493,8 @@ path = directory ().absolutePath (); - QStringList filters = nameFilters (); - idx = filters.indexOf (selectedNameFilter ()) + 1; + QStringList name_filters = nameFilters (); + idx = name_filters.indexOf (selectedNameFilter ()) + 1; // send the selected info emit finish_input (string_result, path, idx);
--- a/libinterp/corefcn/bitfcns.cc +++ b/libinterp/corefcn/bitfcns.cc @@ -24,6 +24,8 @@ #include <config.h> #endif +#include <limits> + #include "str-vec.h" #include "quit.h" @@ -588,7 +590,7 @@ mask = mask >> (bits_in_mantissa - nbits); else if (nbits < 1) mask = 0; - int bits_in_type = sizeof (double) * CHAR_BIT; + int bits_in_type = sizeof (double) * std::numeric_limits<unsigned char>::digits; NDArray m = m_arg.array_value (); DO_BITSHIFT ( ); } @@ -601,7 +603,7 @@ mask = mask >> (bits_in_mantissa - nbits); else if (nbits < 1) mask = 0; - int bits_in_type = sizeof (float) * CHAR_BIT; + int bits_in_type = sizeof (float) * std::numeric_limits<unsigned char>::digits; FloatNDArray m = m_arg.float_array_value (); DO_BITSHIFT (Float); }
--- a/libinterp/corefcn/dirfns.cc +++ b/libinterp/corefcn/dirfns.cc @@ -94,11 +94,16 @@ DEFUN (cd, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Command} {} cd dir\n\ -@deftypefnx {Command} {} chdir dir\n\ -Change the current working directory to @var{dir}. If @var{dir} is\n\ -omitted, the current directory is changed to the user's home\n\ -directory. For example,\n\ +@deftypefn {Command} {} cd @var{dir}\n\ +@deftypefnx {Command} {} cd\n\ +@deftypefnx {Built-in Function} {@var{old_dir} =} cd @var{dir}\n\ +@deftypefnx {Command} {} chdir @dots{}\n\ +Change the current working directory to @var{dir}.\n\ +\n\ +If @var{dir} is omitted, the current directory is changed to the user's home\n\ +directory (@qcode{\"~\"}).\n\ +\n\ +For example,\n\ \n\ @example\n\ cd ~/octave\n\ @@ -108,7 +113,13 @@ changes the current working directory to @file{~/octave}. If the\n\ directory does not exist, an error message is printed and the working\n\ directory is not changed.\n\ -@seealso{mkdir, rmdir, dir}\n\ +\n\ +@code{chdir} is an alias for @code{cd} and can be used in all of the same\n\ +calling formats.\n\ +\n\ +Compatibility Note: When called with no arguments, @sc{matlab} prints the\n\ +present working directory rather than changing to the user's home directory.\n\ +@seealso{pwd, mkdir, rmdir, dir, ls}\n\ @end deftypefn") { octave_value_list retval; @@ -120,30 +131,22 @@ if (error_state) return retval; + if (nargout > 0) + retval = octave_value (octave_env::get_current_directory ()); + if (argc > 1) { std::string dirname = argv[1]; - if (dirname.length () > 0 - && ! octave_change_to_directory (dirname)) - { - return retval; - } + if (dirname.length () > 0) + octave_change_to_directory (dirname); } else { - // Behave like Unixy shells for "cd" by itself, but be Matlab - // compatible if doing "current_dir = cd". + std::string home_dir = octave_env::get_home_directory (); - if (nargout == 0) - { - std::string home_dir = octave_env::get_home_directory (); - - if (home_dir.empty () || ! octave_change_to_directory (home_dir)) - return retval; - } - else - retval = octave_value (octave_env::get_current_directory ()); + if (! home_dir.empty ()) + octave_change_to_directory (home_dir); } return retval; @@ -153,9 +156,10 @@ DEFUN (pwd, , , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} pwd ()\n\ +@deftypefn {Built-in Function} {} pwd ()\n\ +@deftypefnx {Built-in Function} {@var{dir} =} pwd ()\n\ Return the current working directory.\n\ -@seealso{dir, ls}\n\ +@seealso{cd, dir, ls, mkdir, rmdir}\n\ @end deftypefn") { return octave_value (octave_env::get_current_directory ()); @@ -163,14 +167,16 @@ DEFUN (readdir, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{files}, @var{err}, @var{msg}] =} readdir (@var{dir})\n\ -Return names of the files in the directory @var{dir} as a cell array of\n\ -strings. If an error occurs, return an empty cell array in @var{files}.\n\ +@deftypefn {Built-in Function} {@var{files} =} readdir (@var{dir})\n\ +@deftypefnx {Built-in Function} {[@var{files}, @var{err}, @var{msg}] =} readdir (@var{dir})\n\ +Return the names of files in the directory @var{dir} as a cell array of\n\ +strings.\n\ \n\ +If an error occurs, return an empty cell array in @var{files}.\n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ -@seealso{ls, dir, glob}\n\ +@seealso{ls, dir, glob, what}\n\ @end deftypefn") { octave_value_list retval; @@ -207,20 +213,24 @@ return retval; } -// FIXME -- should maybe also allow second arg to specify -// mode? OTOH, that might cause trouble with compatibility later... +// FIXME: should maybe also allow second arg to specify mode? +// OTOH, that might cause trouble with compatibility later... DEFUNX ("mkdir", Fmkdir, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{dir})\n\ -@deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{parent}, @var{dir})\n\ +@deftypefn {Built-in Function} {} mkdir @var{dir}\n\ +@deftypefnx {Built-in Function} {} mkdir (@var{parent}, @var{dir})\n\ +@deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@dots{})\n\ Create a directory named @var{dir} in the directory @var{parent}.\n\ \n\ -If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\ -character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\ -system-dependent error message, and @var{msgid} contains a unique\n\ -message identifier.\n\ -@seealso{rmdir}\n\ +If no @var{parent} directory is specified the present working directory is\n\ +used.\n\ +\n\ +If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty\n\ +character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a\n\ +system-dependent error message, and @var{msgid} contains a unique message\n\ +identifier.\n\ +@seealso{rmdir, pwd, cd}\n\ @end deftypefn") { octave_value_list retval; @@ -295,18 +305,19 @@ DEFUNX ("rmdir", Frmdir, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir})\n\ -@deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir}, \"s\")\n\ +@deftypefn {Built-in Function} {} rmdir @var{dir}\n\ +@deftypefnx {Built-in Function} {} rmdir (@var{dir}, \"s\")\n\ +@deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@dots{})\n\ Remove the directory named @var{dir}.\n\ \n\ -If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\ -character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\ -system-dependent error message, and @var{msgid} contains a unique\n\ -message identifier.\n\ +If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty\n\ +character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a\n\ +system-dependent error message, and @var{msgid} contains a unique message\n\ +identifier.\n\ \n\ If the optional second parameter is supplied with value @qcode{\"s\"},\n\ recursively remove all subdirectories as well.\n\ -@seealso{mkdir, confirm_recursive_rmdir}\n\ +@seealso{mkdir, confirm_recursive_rmdir, pwd}\n\ @end deftypefn") { octave_value_list retval; @@ -369,13 +380,14 @@ DEFUNX ("link", Flink, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} link (@var{old}, @var{new})\n\ +@deftypefn {Built-in Function} {} link @var{old} @var{new}\n\ +@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} link (@var{old}, @var{new})\n\ Create a new link (also known as a hard link) to an existing file.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ -@seealso{symlink}\n\ +@seealso{symlink, unlink, readlink, lstat}\n\ @end deftypefn") { octave_value_list retval; @@ -401,10 +413,9 @@ int status = octave_link (from, to, msg); - retval(0) = status; - if (status < 0) retval(1) = msg; + retval(0) = status; } } } @@ -416,13 +427,14 @@ DEFUNX ("symlink", Fsymlink, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} symlink (@var{old}, @var{new})\n\ +@deftypefn {Built-in Function} {} symlink @var{old} @var{new}\n\ +@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} symlink (@var{old}, @var{new})\n\ Create a symbolic link @var{new} which contains the string @var{old}.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ -@seealso{link, readlink}\n\ +@seealso{link, unlink, readlink, lstat}\n\ @end deftypefn") { octave_value_list retval; @@ -448,10 +460,9 @@ int status = octave_symlink (from, to, msg); - retval(0) = status; - if (status < 0) retval(1) = msg; + retval(0) = status; } } } @@ -463,14 +474,15 @@ DEFUNX ("readlink", Freadlink, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{result}, @var{err}, @var{msg}] =} readlink (@var{symlink})\n\ +@deftypefn {Built-in Function} {} readlink @var{symlink}\n\ +@deftypefnx {Built-in Function} {[@var{result}, @var{err}, @var{msg}] =} readlink (@var{symlink})\n\ Read the value of the symbolic link @var{symlink}.\n\ \n\ If successful, @var{result} contains the contents of the symbolic link\n\ -@var{symlink}, @var{err} is 0 and @var{msg} is an empty string.\n\ -Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ -system-dependent error message.\n\ -@seealso{link, symlink}\n\ +@var{symlink}, @var{err} is 0, and @var{msg} is an empty string.\n\ +Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\ +error message.\n\ +@seealso{lstat, symlink, link, unlink, delete}\n\ @end deftypefn") { octave_value_list retval; @@ -506,13 +518,14 @@ DEFUNX ("rename", Frename, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} rename (@var{old}, @var{new})\n\ +@deftypefn {Built-in Function} {} rename @var{old} @var{new}\n\ +@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} rename (@var{old}, @var{new})\n\ Change the name of file @var{old} to @var{new}.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ -@seealso{ls, dir}\n\ +@seealso{movefile, copyfile, ls, dir}\n\ @end deftypefn") { octave_value_list retval; @@ -538,10 +551,9 @@ int status = octave_rename (from, to, msg); - retval(0) = status; - if (status < 0) retval(1) = msg; + retval(0) = status; } } } @@ -571,9 +583,8 @@ matches any of the enclosed characters.\n\ @end table\n\ \n\ -Tilde expansion\n\ -is performed on each of the patterns before looking for matching file\n\ -names. For example:\n\ +Tilde expansion is performed on each of the patterns before looking for\n\ +matching file names. For example:\n\ \n\ @example\n\ ls\n\ @@ -597,7 +608,7 @@ [2,1] = file2\n\ @}\n\ @end example\n\ -@seealso{ls, dir, readdir}\n\ +@seealso{ls, dir, readdir, what, fnmatch}\n\ @end deftypefn") { octave_value retval; @@ -656,7 +667,7 @@ DEFUNX ("fnmatch", Ffnmatch, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fnmatch (@var{pattern}, @var{string})\n\ -Return 1 or zero for each element of @var{string} that matches any of\n\ +Return true or false for each element of @var{string} that matches any of\n\ the elements of the string array @var{pattern}, using the rules of\n\ filename pattern matching. For example:\n\ \n\ @@ -666,6 +677,7 @@ @result{} [ 1; 1; 0 ]\n\ @end group\n\ @end example\n\ +@seealso{glob, regexp}\n\ @end deftypefn") { octave_value retval; @@ -783,6 +795,7 @@ When called from inside a function with the @qcode{\"local\"} option, the\n\ variable is changed locally for the function and any subroutines it calls. \n\ The original variable value is restored when exiting the function.\n\ +@seealso{rmdir}\n\ @end deftypefn") { return SET_INTERNAL_VARIABLE (confirm_recursive_rmdir);
--- a/libinterp/corefcn/max.cc +++ b/libinterp/corefcn/max.cc @@ -663,8 +663,10 @@ @deftypefn {Built-in Function} {} cummin (@var{x})\n\ @deftypefnx {Built-in Function} {} cummin (@var{x}, @var{dim})\n\ @deftypefnx {Built-in Function} {[@var{w}, @var{iw}] =} cummin (@var{x})\n\ -Return the cumulative minimum values along dimension @var{dim}. If @var{dim}\n\ -is unspecified it defaults to column-wise operation. For example:\n\ +Return the cumulative minimum values along dimension @var{dim}.\n\ +\n\ +If @var{dim} is unspecified it defaults to column-wise operation. For\n\ +example:\n\ \n\ @example\n\ @group\n\ @@ -673,40 +675,52 @@ @end group\n\ @end example\n\ \n\ -\n\ -The call\n\ -\n\ -@example\n\ - [w, iw] = cummin (x)\n\ -@end example\n\ -\n\ -@noindent\n\ -with @code{x} a vector, is equivalent to the following code:\n\ +If called with two output arguments the index of the minimum value is also\n\ +returned.\n\ \n\ @example\n\ @group\n\ -w = iw = zeros (size (x));\n\ -for i = 1:length (x)\n\ - [w(i), iw(i)] = max (x(1:i));\n\ -endfor\n\ +[w, iw] = cummin ([5 4 6 2 3 1])\n\ +@result{}\n\ +w = 5 4 4 2 2 1\n\ +iw = 1 2 2 4 4 6\n\ @end group\n\ @end example\n\ \n\ -@noindent\n\ -but computed in a much faster manner.\n\ @seealso{cummax, min, max}\n\ @end deftypefn") { return do_cumminmax_body (args, nargout, true); } +/* +%!assert (cummin ([1, 4, 2, 3]), [1 1 1 1]) +%!assert (cummin ([1; -10; 5; -2]), [1; -10; -10; -10]) +%!assert (cummin ([4, i; -2, 2]), [4, i; -2, i]) + +%!test +%! x = reshape (1:8, [2,2,2]); +%! assert (cummin (x, 1), reshape ([1 1 3 3 5 5 7 7], [2,2,2])); +%! assert (cummin (x, 2), reshape ([1 2 1 2 5 6 5 6], [2,2,2])); +%! [w, iw] = cummin (x, 3); +%! assert (ndims (w), 3); +%! assert (w, repmat ([1 3; 2 4], [1 1 2])); +%! assert (ndims (iw), 3); +%! assert (iw, ones (2,2,2)); + +%!error cummin () +%!error cummin (1, 2, 3) +*/ + DEFUN (cummax, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} cummax (@var{x})\n\ @deftypefnx {Built-in Function} {} cummax (@var{x}, @var{dim})\n\ -@deftypefnx {Built-in Function} {[@var{w}, @var{iw}] =} cummax (@var{x})\n\ -Return the cumulative maximum values along dimension @var{dim}. If @var{dim}\n\ -is unspecified it defaults to column-wise operation. For example:\n\ +@deftypefnx {Built-in Function} {[@var{w}, @var{iw}] =} cummax (@dots{})\n\ +Return the cumulative maximum values along dimension @var{dim}.\n\ +\n\ +If @var{dim} is unspecified it defaults to column-wise operation. For\n\ +example:\n\ \n\ @example\n\ @group\n\ @@ -715,28 +729,40 @@ @end group\n\ @end example\n\ \n\ -The call\n\ -\n\ -@example\n\ -[w, iw] = cummax (x, dim)\n\ -@end example\n\ -\n\ -@noindent\n\ -with @code{x} a vector, is equivalent to the following code:\n\ +If called with two output arguments the index of the maximum value is also\n\ +returned.\n\ \n\ @example\n\ @group\n\ -w = iw = zeros (size (x));\n\ -for i = 1:length (x)\n\ - [w(i), iw(i)] = max (x(1:i));\n\ -endfor\n\ +[w, iw] = cummax ([1 3 2 6 4 5])\n\ +@result{}\n\ +w = 1 3 3 6 6 6\n\ +iw = 1 2 2 4 4 4\n\ @end group\n\ @end example\n\ \n\ -@noindent\n\ -but computed in a much faster manner.\n\ @seealso{cummin, max, min}\n\ @end deftypefn") { return do_cumminmax_body (args, nargout, false); } + +/* +%!assert (cummax ([1, 4, 2, 3]), [1 4 4 4]) +%!assert (cummax ([1; -10; 5; -2]), [1; 1; 5; 5]) +%!assert (cummax ([4, i 4.9, -2, 2, 3+4i]), [4, 4, 4.9, 4.9, 4.9, 3+4i]) + +%!test +%! x = reshape (8:-1:1, [2,2,2]); +%! assert (cummax (x, 1), reshape ([8 8 6 6 4 4 2 2], [2,2,2])); +%! assert (cummax (x, 2), reshape ([8 7 8 7 4 3 4 3], [2,2,2])); +%! [w, iw] = cummax (x, 3); +%! assert (ndims (w), 3); +%! assert (w, repmat ([8 6; 7 5], [1 1 2])); +%! assert (ndims (iw), 3); +%! assert (iw, ones (2,2,2)); + +%!error cummax () +%!error cummax (1, 2, 3) +*/ +
--- a/libinterp/corefcn/str2double.cc +++ b/libinterp/corefcn/str2double.cc @@ -320,13 +320,20 @@ more digits. The special input values @code{Inf}, @code{NaN}, and @code{NA}\n\ are also accepted.\n\ \n\ -@var{s} may also be a character matrix, in which case the conversion is\n\ -repeated for each row. Or @var{s} may be a cell array of strings, in which\n\ -case each element is converted and an array of the same dimensions is\n\ -returned.\n\ +@var{s} may be a character string, character matrix, or cell array.\n\ +For character arrays the conversion is repeated for every row, and\n\ +a double or complex array is returned. Empty rows in @var{s} are deleted\n\ +and not returned in the numeric array. For cell arrays each character\n\ +string element is processed and a double or complex array of the same\n\ +dimensions as @var{s} is returned.\n\ \n\ -@code{str2double} returns NaN for elements of @var{s} which cannot be\n\ -converted.\n\ +For unconvertible scalar or character string input @code{str2double} returns\n\ +a NaN@. Similarly, for character array input @code{str2double} returns a\n\ +NaN for any row of @var{s} that could not be converted. For a cell array,\n\ +@code{str2double} returns a NaN for any element of @var{s} for which\n\ +conversion fails. Note that numeric elements in a mixed string/numeric\n\ +cell array are not strings and the conversion will fail for these elements\n\ +and return NaN.\n\ \n\ @code{str2double} can replace @code{str2num}, and it avoids the security\n\ risk of using @code{eval} on unknown data.\n\ @@ -339,7 +346,11 @@ print_usage (); else if (args(0).is_string ()) { - if (args(0).rows () == 1 && args(0).ndims () == 2) + if (args(0).rows () == 0 || args(0).columns () == 0) + { + retval = Matrix (1, 1, octave_NaN); + } + else if (args(0).rows () == 1 && args(0).ndims () == 2) { retval = str2double1 (args(0).string_value ()); } @@ -366,7 +377,7 @@ } } else - retval = NDArray (args(0).dims (), octave_NaN); + retval = Matrix (1, 1, octave_NaN); return retval; @@ -400,5 +411,8 @@ %!assert (str2double ("-i*NaN - Inf"), complex (-Inf, -NaN)) %!assert (str2double ({"abc", "4i"}), [NaN + 0i, 4i]) %!assert (str2double ({2, "4i"}), [NaN + 0i, 4i]) -%!assert (str2double (zeros (3,1,2)), NaN (3,1,2)) -*/ +%!assert (str2double (zeros (3,1,2)), NaN) +%!assert (str2double (''), NaN) +%!assert (str2double ([]), NaN) +%!assert (str2double (char(zeros(3,0))), NaN) + */
--- a/libinterp/corefcn/strfind.cc +++ b/libinterp/corefcn/strfind.cc @@ -149,20 +149,29 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{idx} =} strfind (@var{str}, @var{pattern})\n\ @deftypefnx {Built-in Function} {@var{idx} =} strfind (@var{cellstr}, @var{pattern})\n\ +@deftypefnx {Built-in Function} {@var{idx} =} strfind (@dots{}, \"overlaps\", @var{val})\n\ Search for @var{pattern} in the string @var{str} and return the\n\ starting index of every such occurrence in the vector @var{idx}.\n\ +\n\ If there is no such occurrence, or if @var{pattern} is longer\n\ than @var{str}, then @var{idx} is the empty array @code{[]}.\n\ +The optional argument @qcode{\"overlaps\"} determines whether the pattern\n\ +can match at every position in @var{str} (true), or only for unique\n\ +occurrences of the complete pattern (false). The default is true.\n\ \n\ If a cell array of strings @var{cellstr} is specified\n\ -then @var{idx} is a cell array of vectors, as specified\n\ -above. Examples:\n\ +then @var{idx} is a cell array of vectors, as specified above.\n\ +\n\ +Examples:\n\ \n\ @example\n\ @group\n\ strfind (\"abababa\", \"aba\")\n\ @result{} [1, 3, 5]\n\ \n\ +strfind (\"abababa\", \"aba\", \"overlaps\", false)\n\ + @result{} [1, 5]\n\ +\n\ strfind (@{\"abababa\", \"bebebe\", \"ab\"@}, \"aba\")\n\ @result{}\n\ @{\n\ @@ -321,10 +330,20 @@ DEFUN (strrep, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} strrep (@var{s}, @var{ptn}, @var{rep})\n\ -@deftypefnx {Built-in Function} {} strrep (@var{s}, @var{ptn}, @var{rep}, \"overlaps\", @var{o})\n\ -Replace all occurrences of the substring @var{ptn} in the string @var{s}\n\ -with the string @var{rep} and return the result. For example:\n\ +@deftypefn {Built-in Function} {@var{newstr} =} strrep (@var{str}, @var{ptn}, @var{rep})\n\ +@deftypefnx {Built-in Function} {@var{newstr} =} strrep (@var{cellstr}, @var{ptn}, @var{rep})\n\ +@deftypefnx {Built-in Function} {@var{newstr} =} strrep (@dots{}, \"overlaps\", @var{val})\n\ +Replace all occurrences of the pattern @var{ptn} in the string @var{str}\n\ +with the string @var{rep} and return the result.\n\ +\n\ +The optional argument @qcode{\"overlaps\"} determines whether the pattern\n\ +can match at every position in @var{str} (true), or only for unique\n\ +occurrences of the complete pattern (false). The default is true.\n\ +\n\ +@var{s} may also be a cell array of strings, in which case the replacement is\n\ +done for each element and a cell array is returned.\n\ +\n\ +Example:\n\ \n\ @example\n\ @group\n\ @@ -333,8 +352,6 @@ @end group\n\ @end example\n\ \n\ -@var{s} may also be a cell array of strings, in which case the replacement is\n\ -done for each element and a cell array is returned.\n\ @seealso{regexprep, strfind, findstr}\n\ @end deftypefn") {
--- a/libinterp/corefcn/syscalls.cc +++ b/libinterp/corefcn/syscalls.cc @@ -749,11 +749,13 @@ DEFUNX ("lstat", Flstat, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ +@deftypefn {Built-in Function} {@var{info} =} lstat (@var{symlink})\n\ +@deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ Return a structure @var{info} containing information about the symbolic link\n\ -@var{symlink}. The function outputs are described in the documentation for\n\ -@code{stat}.\n\ -@seealso{stat}\n\ +@var{symlink}.\n\ +\n\ +The function outputs are described in the documentation for @code{stat}.\n\ +@seealso{stat, symlink}\n\ @end deftypefn") { octave_value_list retval; @@ -777,12 +779,14 @@ DEFUNX ("mkfifo", Fmkfifo, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ -Create a @var{fifo} special file named @var{name} with file mode @var{mode}\n\ +@deftypefn {Built-in Function} {} mkfifo (@var{name}, @var{mode})\n\ +@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ +Create a FIFO special file named @var{name} with file mode @var{mode}\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ +@seealso{pipe}\n\ @end deftypefn") { octave_value_list retval; @@ -837,6 +841,7 @@ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ system-dependent error message.\n\ +@seealso{mkfifo}\n\ @end deftypefn") { octave_value_list retval; @@ -975,6 +980,7 @@ @result{} err = 0\n\ @result{} msg =\n\ @end example\n\ +@seealso{lstat, ls, dir}\n\ @end deftypefn") { octave_value_list retval; @@ -1013,8 +1019,9 @@ DEFUNX ("S_ISREG", FS_ISREG, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ -Return true if @var{mode} corresponds to a regular file. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a regular file.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1038,8 +1045,9 @@ DEFUNX ("S_ISDIR", FS_ISDIR, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ -Return true if @var{mode} corresponds to a directory. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a directory.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1063,8 +1071,9 @@ DEFUNX ("S_ISCHR", FS_ISCHR, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ -Return true if @var{mode} corresponds to a character device. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a character device.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1088,8 +1097,9 @@ DEFUNX ("S_ISBLK", FS_ISBLK, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ -Return true if @var{mode} corresponds to a block device. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a block device.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1113,8 +1123,9 @@ DEFUNX ("S_ISFIFO", FS_ISFIFO, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ -Return true if @var{mode} corresponds to a fifo. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a fifo.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1138,8 +1149,9 @@ DEFUNX ("S_ISLNK", FS_ISLNK, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ -Return true if @var{mode} corresponds to a symbolic link. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a symbolic link.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") { @@ -1163,8 +1175,9 @@ DEFUNX ("S_ISSOCK", FS_ISSOCK, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ -Return true if @var{mode} corresponds to a socket. The value\n\ -of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ +Return true if @var{mode} corresponds to a socket.\n\ +\n\ +The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ @seealso{stat, lstat}\n\ @end deftypefn") {
--- a/libinterp/corefcn/typecast.cc +++ b/libinterp/corefcn/typecast.cc @@ -25,7 +25,7 @@ #include <config.h> #endif -#include <climits> +#include <limits> #include "mx-base.h" @@ -242,9 +242,9 @@ do_bitpack (const boolNDArray& bitp) { typedef typename ArrayType::element_type T; - octave_idx_type n = bitp.numel () / (sizeof (T) * CHAR_BIT); + octave_idx_type n = bitp.numel () / (sizeof (T) * std::numeric_limits<unsigned char>::digits); - if (n * static_cast<int> (sizeof (T)) * CHAR_BIT == bitp.numel ()) + if (n * static_cast<int> (sizeof (T)) * std::numeric_limits<unsigned char>::digits == bitp.numel ()) { ArrayType retval (get_vec_dims (bitp.dims (), n)); @@ -257,11 +257,11 @@ for (octave_idx_type i = 0; i < m; i++) { char c = bits[0]; - for (int j = 1; j < CHAR_BIT; j++) + for (int j = 1; j < std::numeric_limits<unsigned char>::digits; j++) c |= bits[j] << j; packed[i] = c; - bits += CHAR_BIT; + bits += std::numeric_limits<unsigned char>::digits; } return retval; @@ -361,22 +361,22 @@ do_bitunpack (const ArrayType& array) { typedef typename ArrayType::element_type T; - octave_idx_type n = array.numel () * sizeof (T) * CHAR_BIT; + octave_idx_type n = array.numel () * sizeof (T) * std::numeric_limits<unsigned char>::digits; boolNDArray retval (get_vec_dims (array.dims (), n)); const char *packed = reinterpret_cast<const char *> (array.fortran_vec ()); bool *bits = retval.fortran_vec (); - octave_idx_type m = n / CHAR_BIT; + octave_idx_type m = n / std::numeric_limits<unsigned char>::digits; for (octave_idx_type i = 0; i < m; i++) { char c = packed[i]; bits[0] = c & 1; - for (int j = 1; j < CHAR_BIT; j++) + for (int j = 1; j < std::numeric_limits<unsigned char>::digits; j++) bits[j] = (c >>= 1) & 1; - bits += CHAR_BIT; + bits += std::numeric_limits<unsigned char>::digits; } return retval;
--- a/liboctave/util/data-conv.cc +++ b/liboctave/util/data-conv.cc @@ -25,10 +25,10 @@ #endif #include <cctype> -#include <climits> #include <cstdlib> #include <iostream> +#include <limits> #include <vector> #include "byte-swap.h" @@ -45,7 +45,7 @@ #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ do \ { \ - int sz = BITS / CHAR_BIT; \ + int sz = BITS / std::numeric_limits<unsigned char>::digits; \ if (sizeof (TQ char) == sz) \ VAL = oct_data_conv::dt_ ## Q ## char; \ else if (sizeof (TQ short) == sz) \ @@ -64,7 +64,7 @@ #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ do \ { \ - int sz = BITS / CHAR_BIT; \ + int sz = BITS / std::numeric_limits<unsigned char>::digits; \ if (sizeof (TQ char) == sz) \ VAL = oct_data_conv::dt_ ## Q ## char; \ else if (sizeof (TQ short) == sz) \ @@ -82,7 +82,7 @@ #define FIND_SIZED_FLOAT_TYPE(VAL, BITS) \ do \ { \ - int sz = BITS / CHAR_BIT; \ + int sz = BITS / std::numeric_limits<unsigned char>::digits; \ if (sizeof (float) == sz) \ VAL = oct_data_conv::dt_float; \ else if (sizeof (double) == sz) \ @@ -94,8 +94,9 @@ // I'm not sure it is worth the trouble, but let's use a lookup table // for the types that are supposed to be a specific number of bits -// wide. Given the macros above, this should work as long as CHAR_BIT -// is a multiple of 8 and there are types with the right sizes. +// wide. Given the macros above, this should work as long as +// std::numeric_limits<unsigned char>::digits is a multiple of 8 and +// there are types with the right sizes. // // The sized data type lookup table has the following format: //
--- a/scripts/general/isdir.m +++ b/scripts/general/isdir.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} isdir (@var{f}) ## Return true if @var{f} is a directory. -## @seealso{is_absolute_filename, is_rooted_relative_filename} +## @seealso{exist, stat, is_absolute_filename, is_rooted_relative_filename} ## @end deftypefn function retval = isdir (f)
--- a/scripts/help/type.m +++ b/scripts/help/type.m @@ -19,24 +19,24 @@ ## -*- texinfo -*- ## @deftypefn {Command} {} type @var{name} @dots{} ## @deftypefnx {Command} {} type -q @var{name} @dots{} -## @deftypefnx {Function File} {dfns =} type ("@var{name}", @dots{}) -## Display the definition of each @var{name} that refers to a function. +## @deftypefnx {Function File} {text =} type ("@var{name}", @dots{}) +## Display the contents of @var{name} which may be a file, function (m-file), +## variable, operator, or keyword. ## -## Normally also displays whether each @var{name} is user-defined or built-in; -## the @option{-q} option suppresses this behavior. +## @code{type} normally prepends a header line describing the category +## of @var{name} such as function or variable; The @option{-q} option +## suppresses this behavior. ## -## If an output argument is requested nothing is displayed. Instead, a cell -## array of strings is returned, where each element corresponds to the -## definition of each requested function. +## If no output variable is used the contents are displayed on screen. +## Otherwise, a cell array of strings is returned, where each element +## corresponds to the contents of each requested function. ## @end deftypefn -function retval = type (varargin) - ## Parse input +function text = type (varargin) + if (nargin == 0) - error ("type: not enough input arguments"); - endif - - if (!iscellstr (varargin)) + print_usage (); + elseif (! iscellstr (varargin)) error ("type: input arguments must be strings"); endif @@ -44,18 +44,18 @@ idx = strcmpi (varargin, "-q") | strcmpi (varargin, "-quiet"); if (any (idx)) quiet = true; - varargin (idx) = []; + varargin(idx) = []; endif if (nargout > 0) - retval = cell (size (varargin)); + text = cell (size (varargin)); endif for n = 1:length (varargin) - name = varargin {n}; + name = varargin{n}; ## Find function and get its code - text = ""; + txt = ""; cmd = sprintf ("exist ('%s')", name); e = evalin ("caller", cmd); if (e == 1) @@ -63,17 +63,20 @@ cmd = sprintf ("disp (%s);", name); desc = evalin ("caller", cmd); if (quiet) - text = desc; + txt = desc; else - text = sprintf ("%s is a variable\n%s", name, desc); + txt = sprintf ("%s is a variable\n%s", name, desc); endif elseif (e == 2) ## m-file or ordinary file file = which (name); - if (isempty (file)) + if (length (file) > 2) + ext = file(end-1:end); + endif + if (isempty (file) || ! strcmpi (ext, ".m")) ## 'name' is an ordinary file, and not a function name. - ## FIXME: Should we just print it anyway? - error ("type: '%s' undefined\n", name); + file = file_in_loadpath (name); + quiet = true; endif ## Read the file @@ -85,28 +88,27 @@ fclose (fid); if (quiet) - text = contents; + txt = contents; else - text = sprintf ("%s is the user-defined function defined from: %s\n\n%s", + txt = sprintf ("%s is the user-defined function defined from: %s\n\n%s", name, file, contents); endif elseif (e == 3) - text = sprintf ("%s is a dynamically-linked function", name); + txt = sprintf ("%s is a dynamically-linked function", name); elseif (e == 5) - text = sprintf ("%s is a built-in function", name); + txt = sprintf ("%s is a built-in function", name); elseif (any (strcmp (__operators__ (), name))) - text = sprintf ("%s is an operator", name); + txt = sprintf ("%s is an operator", name); elseif (any (strcmp (__keywords__ (), name))) - text = sprintf ("%s is a keyword", name); + txt = sprintf ("%s is a keyword", name); else error ("type: '%s' undefined\n", name); endif - ## Should we return the text or print if if (nargout == 0) - disp (text); + disp (txt); else - retval {n} = text; + text{n} = txt; endif endfor endfunction @@ -114,14 +116,25 @@ %!test %! var = 1; -%! typestr = type ("var"); -%! typestr = typestr{1}(1:17); +%! text = type ("var"); +%! typestr = text{1}(1:17); %! assert (typestr, "var is a variable"); +%!test +%! text = type ("ls"); +%! typestr = text{1}(1:31); +%! assert (typestr, "ls is the user-defined function"); + +%!test +%! text = type ("ls", "-q"); +%! typestr = text{1}(1:21); +%! assert (typestr, "## Copyright (C) 2006"); + %!assert (type ("amd"){1}, "amd is a dynamically-linked function") %!assert (type ("cat"){1}, "cat is a built-in function") %!assert (type ("+"){1}, "+ is an operator") %!assert (type ("end"){1}, "end is a keyword") -%!error (type ('NO_NAME')) + +%!error type () +%!error <'__NO_NAME__' undefined> type ('__NO_NAME__') -
--- a/scripts/miscellaneous/copyfile.m +++ b/scripts/miscellaneous/copyfile.m @@ -31,7 +31,7 @@ ## system-dependent error message, and @var{msgid} contains a unique message ## identifier. Note that the status code is exacly opposite that of the ## @code{system} command. -## @seealso{movefile, glob} +## @seealso{movefile, rename, unlink, delete, glob} ## @end deftypefn function [status, msg, msgid] = copyfile (f1, f2, force)
--- a/scripts/miscellaneous/dir.m +++ b/scripts/miscellaneous/dir.m @@ -17,40 +17,46 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} dir (@var{directory}) +## @deftypefn {Function File} {} dir +## @deftypefnx {Function File} {} dir (@var{directory}) ## @deftypefnx {Function File} {[@var{list}] =} dir (@var{directory}) -## Display file listing for directory @var{directory}. If a return -## value is requested, return a structure array with the fields +## Display file listing for directory @var{directory}. +## +## If @var{directory} is not specified then list the present working directory. +## +## If a return value is requested, return a structure array with the fields ## -## @example -## @group -## name -## bytes -## date -## isdir -## statinfo -## @end group -## @end example +## @table @asis +## @item name +## File or directory name. +## @item date +## Timestamp of file modification (string value). +## @item bytes +## File size in bytes. +## @item isdir +## True if name is a directory. +## @item datenum +## Timestamp of file modification as serial date number (double). +## @item statinfo +## Information structure returned from @code{stat}. +## @end table ## -## @noindent -## where @code{statinfo} is the structure returned from @code{stat}. -## -## If @var{directory} is not a directory, return information about the -## named @var{filename}. @var{directory} may be a list of directories -## specified either by name or with wildcard characters (like * and ?) -## which will be expanded with glob. +## If @var{directory} is a filename, rather than a directory, then return +## information about the named file. @var{directory} may be a list of +## directories specified either by name or with wildcard characters (like * +## and ?) which will be expanded with @code{glob}. ## ## Note that for symbolic links, @code{dir} returns information about -## the file that the symbolic link points to instead of the link itself. +## the file that the symbolic link points to rather than the link itself. ## However, if the link points to a nonexistent file, @code{dir} returns ## information about the link. -## @seealso{ls, stat, lstat, readdir, glob, filesep} +## @seealso{ls, readdir, glob, what, stat} ## @end deftypefn ## Author: jwe -## FIXME -- this is quite slow for large directories, so perhaps -## it should be converted to C++. +## FIXME: This is quite slow for large directories, so perhaps +## it should be converted to C++. function retval = dir (directory)
--- a/scripts/miscellaneous/ls.m +++ b/scripts/miscellaneous/ls.m @@ -32,7 +32,7 @@ ## The @code{dir} and @code{ls} commands are implemented by calling your ## system's directory listing command, so the available options may vary ## from system to system. -## @seealso{dir, stat, readdir, glob, filesep, ls_command} +## @seealso{dir, readdir, glob, what, stat, filesep, ls_command} ## @end deftypefn ## Author: jwe
--- a/scripts/miscellaneous/movefile.m +++ b/scripts/miscellaneous/movefile.m @@ -35,7 +35,7 @@ ## system-dependent error message, and @var{msgid} contains a unique message ## identifier. Note that the status code is exacly opposite that of the ## @code{system} command. -## @seealso{rename, copyfile, glob} +## @seealso{rename, copyfile, unlink, delete, glob} ## @end deftypefn function [status, msg, msgid] = movefile (f1, f2, force)
--- a/scripts/optimization/optimget.m +++ b/scripts/optimization/optimget.m @@ -33,7 +33,7 @@ endif opts = __all_opts__ (); - idx = strncmpi (opts, parname, numel (parname)); + idx = strncmpi (opts, parname, length (parname)); nmatch = sum (idx);
--- a/scripts/plot/__gnuplot_drawnow__.m +++ b/scripts/plot/__gnuplot_drawnow__.m @@ -225,7 +225,7 @@ otherwise size_str = ""; endswitch - if ((strncmpi (term, "x11", 3) + if ((strcmp (term, "x11") && __gnuplot_has_feature__ ("x11_figure_position")) || (strcmpi (term, "windows") && __gnuplot_has_feature__ ("windows_figure_position")))
--- a/scripts/plot/fill.m +++ b/scripts/plot/fill.m @@ -94,7 +94,7 @@ hlist(end + 1, 1) = htmp; endfor - if (strncmp (old_nxtplt, "replace", 7)) + if (strcmp (old_nxtplt, "replace")) set (hax, "nextplot", old_nxtplt); endif
--- a/scripts/plot/module.mk +++ b/scripts/plot/module.mk @@ -13,7 +13,6 @@ plot/private/__axis_label__.m \ plot/private/__bar__.m \ plot/private/__clabel__.m \ - plot/private/__color_str_rgb__.m \ plot/private/__contour__.m \ plot/private/__default_plot_options__.m \ plot/private/__errcomm__.m \
--- a/scripts/plot/private/__add_default_menu__.m +++ b/scripts/plot/private/__add_default_menu__.m @@ -38,7 +38,6 @@ ## on and then off to force figure to hide menubar. menubar_state = get (fig, "menubar"); set (fig, "menubar", "figure"); - drawnow (); __f = uimenu (fig, "label", "&File", "handlevisibility", "off", "tag", "__default_menu__"); @@ -59,6 +58,11 @@ "tag", "__default_menu__"); uimenu (__h, "label", "A&bout", "enable", "off"); + ## FIXME: This drawnow () must occur after at least one menu item has + ## been defined to avoid sizing issues in new figures. + ## This may lead to flicker. The real fix must be in the C++ code. + drawnow (); + set (fig, "menubar", menubar_state); endif
deleted file mode 100644 --- a/scripts/plot/private/__color_str_rgb__.m +++ /dev/null @@ -1,51 +0,0 @@ -## Copyright (C) 2010-2012 David Bateman -## -## 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} {@var{rgb} =} __color_str_rgb__ (@var{str}) -## Undocumented internal function. -## @end deftypefn - -function rgb = __color_str_rgb__ (str) - - if (ischar (str)) - if (strncmpi (str, "black", 5)) - rgb = [0, 0, 0]; - elseif (strncmpi (str, "red", 3)) - rgb = [1, 0, 0]; - elseif (strncmpi (str, "green", 5)) - rgb = [0, 1, 0]; - elseif (strncmpi (str, "blue", 4)) - rgb = [0, 0, 1]; - - elseif (strncmpi (str, "yellow", 6)) - rgb = [1, 1, 0]; - elseif (strncmpi (str, "magenta", 7)) - rgb = [1, 0, 1]; - elseif (strncmpi (str, "cyan", 4)) - rgb = [0, 1, 1]; - elseif (strncmpi (str, "white", 5)) - rgb = [1, 1, 1]; - else - rgb = [0, 0, 0]; - endif - else - error ("__color_str_rgb__: expecting a string argument"); - endif -endfunction -
--- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -480,7 +480,7 @@ ## Check for facecolor interpolation for surfaces. doing_interp_color = ... - isfield (obj, "facecolor") && strncmp (obj.facecolor, "interp", 6); + isfield (obj, "facecolor") && strcmp (obj.facecolor, "interp"); switch (obj.type) case "image" @@ -547,10 +547,10 @@ withclause{data_idx} = sprintf ("with %s;", imagetype); case "line" - if (strncmp (obj.linestyle, "none", 4) + if (strcmp (obj.linestyle, "none") && (! isfield (obj, "marker") || (isfield (obj, "marker") - && strncmp (obj.marker, "none", 4)))) + && strcmp (obj.marker, "none")))) continue; endif data_idx++; @@ -643,7 +643,7 @@ if (! isnan (xcol) && ! isnan (ycol)) ## Is the patch closed or not - if (strncmp (obj.facecolor, "none", 4)) + if (strcmp (obj.facecolor, "none")) hidden_removal = false; else @@ -684,8 +684,8 @@ titlespec{local_idx} = ['title "' tmp '"']; endif if (isfield (obj, "facecolor")) - if ((strncmp (obj.facecolor, "flat", 4) - || strncmp (obj.facecolor, "interp", 6)) + if ((strcmp (obj.facecolor, "flat") + || strcmp (obj.facecolor, "interp")) && isfield (obj, "cdata")) if (ndims (obj.cdata) == 2 && (columns (obj.cdata) == nc @@ -702,7 +702,7 @@ else ccol = cdat; endif - if (strncmp (obj.facecolor, "flat", 4)) + if (strcmp (obj.facecolor, "flat")) if (isequal (size (ccol), [1, 3])) ## RGB Triplet color = ccol; @@ -718,7 +718,7 @@ r = max (1, min (r, rows (cmap))); color = cmap(r, :); endif - elseif (strncmp (obj.facecolor, "interp", 6)) + elseif (strcmp (obj.facecolor, "interp")) if (nd == 3 && numel (xcol) == 3) ccdat = ccol; if (! isvector (ccdat)) @@ -782,10 +782,10 @@ endif ## patch outline - if (!(strncmp (obj.edgecolor, "none", 4) - && (strncmp (obj.marker, "none", 4) - || (strncmp (obj.markeredgecolor, "none", 4) - && strncmp (obj.markerfacecolor, "none", 4))))) + if (!(strcmp (obj.edgecolor, "none") + && (strcmp (obj.marker, "none") + || (strcmp (obj.markeredgecolor, "none") + && strcmp (obj.markerfacecolor, "none"))))) data_idx++; is_image_data(data_idx) = false; @@ -806,8 +806,8 @@ ## treat them seperately. However, the below allow the scatter ## functions to work as expected, where only one of these values ## is set - if (strncmp (obj.edgecolor, "none", 4)) - if (strncmp (obj.markeredgecolor, "none", 4)) + if (strcmp (obj.edgecolor, "none")) + if (strcmp (obj.markeredgecolor, "none")) ec = obj.markerfacecolor; else ec = obj.markeredgecolor; @@ -816,8 +816,8 @@ ec = obj.edgecolor; endif - if ((strncmp (ec, "flat", 4) - || strncmp (ec, "interp", 6)) + if ((strcmp (ec, "flat") + || strcmp (ec, "interp")) && isfield (obj, "cdata")) if (ndims (obj.cdata) == 2 && (columns (obj.cdata) == nc @@ -834,7 +834,7 @@ else ccol = cdat; endif - if (strncmp (ec, "flat", 4)) + if (strcmp (ec, "flat")) if (numel (ccol) == 3) color = ccol; else @@ -844,7 +844,7 @@ color = "flat"; have_cdata(data_idx) = true; endif - elseif (strncmp (ec, "interp", 6)) + elseif (strcmp (ec, "interp")) if (numel (ccol) == 3) warning ("\"interp\" not supported, using 1st entry of cdata"); color = ccol(1,:); @@ -919,8 +919,8 @@ facesame = true; if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") - && !strncmp (obj.markerfacecolor, "none", 4)) - if (strncmp (obj.markerfacecolor, "auto", 4) + && !strcmp (obj.markerfacecolor, "none")) + if (strcmp (obj.markerfacecolor, "auto") || ! isnumeric (obj.markerfacecolor) || (isnumeric (obj.markerfacecolor) && isequal (color, obj.markerfacecolor))) @@ -969,9 +969,9 @@ endif if (isfield (obj, "markeredgecolor") - && !strncmp (obj.markeredgecolor, "none", 4)) + && !strcmp (obj.markeredgecolor, "none")) if (facesame && !isempty (pt) - && (strncmp (obj.markeredgecolor, "auto", 4) + && (strcmp (obj.markeredgecolor, "auto") || ! isnumeric (obj.markeredgecolor) || (isnumeric (obj.markeredgecolor) && isequal (color, obj.markeredgecolor)))) @@ -1005,7 +1005,7 @@ if (!isempty (pt)) if (! mono) - if (strncmp (obj.markeredgecolor, "auto", 4)) + if (strcmp (obj.markeredgecolor, "auto")) colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", round (255*color)); elseif (isnumeric (obj.markeredgecolor) && ! mono) @@ -1102,8 +1102,8 @@ case "surface" view_map = true; - if (! (strncmp (obj.edgecolor, "none", 4) - && strncmp (obj.facecolor, "none", 4))) + if (! (strcmp (obj.edgecolor, "none") + && strcmp (obj.facecolor, "none"))) data_idx++; is_image_data(data_idx) = false; parametric(data_idx) = false; @@ -1175,12 +1175,12 @@ endif usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3):($4)", ylen, xlen); - flat_interp_face = (strncmp (obj.facecolor, "flat", 4) - || strncmp (obj.facecolor, "interp", 6)); - flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) - || strncmp (obj.edgecolor, "interp", 6)); + flat_interp_face = (strcmp (obj.facecolor, "flat") + || strcmp (obj.facecolor, "interp")); + flat_interp_edge = (strcmp (obj.edgecolor, "flat") + || strcmp (obj.edgecolor, "interp")); - facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4) + facecolor_none_or_white = (strcmp (obj.facecolor, "none") || (isnumeric (obj.facecolor) && all (obj.facecolor == 1))); hidden_removal = false; @@ -1211,11 +1211,11 @@ dord = "depthorder"; endif - if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) + if (flat_interp_face && strcmp (obj.edgecolor, "flat")) fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", interp_str, dord); elseif (!facecolor_none_or_white) - if (strncmp (obj.edgecolor, "none", 4)) + if (strcmp (obj.edgecolor, "none")) if (__gnuplot_has_feature__ ("transparent_surface") && isscalar (obj.facealpha)) fprintf (plot_stream, @@ -1274,7 +1274,7 @@ withclause{data_idx} = sprintf ("with %s linestyle %d", style{3}, data_idx); endif - if (withpm3d && strncmp (style {1}, "linespoints", 11)) + if (withpm3d && strcmp (style{1}, "linespoints")) if (isempty (zz)) len = 3 * xlen; zz = zeros (ylen, len); @@ -1831,8 +1831,8 @@ facesame = true; if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") - && !strncmp (obj.markerfacecolor, "none", 4)) - if (strncmp (obj.markerfacecolor, "auto", 4) + && !strcmp (obj.markerfacecolor, "none")) + if (strcmp (obj.markerfacecolor, "auto") || ! isnumeric (obj.markerfacecolor) || (isnumeric (obj.markerfacecolor) && isequal (color, obj.markerfacecolor))) @@ -1871,14 +1871,14 @@ endif endif if (isfield (obj, "markeredgecolor") - && !strncmp (obj.markeredgecolor, "none", 4)) + && !strcmp (obj.markeredgecolor, "none")) if (facesame && !isempty (pt) - && (strncmp (obj.markeredgecolor, "auto", 4) + && (strcmp (obj.markeredgecolor, "auto") || ! isnumeric (obj.markeredgecolor) || (isnumeric (obj.markeredgecolor) && isequal (color, obj.markeredgecolor)))) if (sidx == 1 && ((length (style {sidx}) == 5 - && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx}))) + && strncmp (style{sidx}, "lines", 5)) || isempty (style {sidx}))) if (! isempty (pt)) style {sidx} = strcat (style{sidx}, "points"); fprintf (plot_stream, " pointtype %s", pt); @@ -1901,7 +1901,7 @@ fprintf (plot_stream, "set style line %d default;\n", idx); fprintf (plot_stream, "set style line %d", idx); if (! mono) - if (strncmp (obj.markeredgecolor, "auto", 4)) + if (strcmp (obj.markeredgecolor, "auto")) fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", round (255*color)); elseif (isnumeric (obj.markeredgecolor) && ! mono) @@ -1945,7 +1945,7 @@ pt = "6"; pt2 = "7"; if (isfield (obj, "markerfacecolor") - || strncmp (obj.markerfacecolor, "none", 4)) + || strcmp (obj.markerfacecolor, "none")) obj.markerfacecolor = "auto"; endif if (isfield (obj, "markersize"))
--- a/scripts/plot/private/__pie__.m +++ b/scripts/plot/private/__pie__.m @@ -114,7 +114,7 @@ set (h, "clim", [1, len]); endif - if (strncmp (caller, "pie3", 4)) + if (strcmp (caller, "pie3")) ln = length (xn); zlvl = 0.35; sx = repmat (xoff + [0, -sind(xn), 0], [2, 1]); @@ -128,7 +128,7 @@ patch(xoff + [0, -sind(xn)], yoff + [0, cosd(xn)], zlvl * ones (1, ln + 1), i); text(xt, yt, zlvl, labels{i})]; - elseif (strncmp (caller, "pie", 3)) + elseif (strcmp (caller, "pie")) if (xt > 0) align = "left"; else @@ -145,10 +145,10 @@ addlistener (gca, "view", {@update_text_pos, hlist}); - if (strncmp (caller, "pie3", 4)) + if (strcmp (caller, "pie3")) axis ([-1.25, 1.25, -1.25, 1.25, -0.05, 0.4], "equal", "off"); view (-37.5, 30); - elseif (strncmp (caller, "pie", 3)) + elseif (strcmp (caller, "pie")) axis ([-1.5, 1.5, -1.5, 1.5], "square", "off"); endif endfunction
--- a/scripts/plot/private/__print_parse_opts__.m +++ b/scripts/plot/private/__print_parse_opts__.m @@ -90,9 +90,9 @@ arg_st.force_solid = 1; elseif (strcmp (arg, "-dashed")) arg_st.force_solid = -1; - elseif (strncmp (arg, "-portrait", numel (arg))) + elseif (strncmp (arg, "-portrait", length (arg))) arg_st.orientation = "portrait"; - elseif (strncmp (arg, "-landscape", numel (arg))) + elseif (strncmp (arg, "-landscape", length (arg))) arg_st.orientation = "landscape"; elseif (strcmp (arg, "-loose")) arg_st.loose = true; @@ -122,14 +122,14 @@ arg_st.pstoedit_binary = arg{10:end}; elseif (strncmpi (arg, "-textalphabits=", 15)) n = find (arg == "="); - if (! isempty (n) && n == numel (arg) - 1 && ismember (arg(end), "124")) + if (! isempty (n) && n == numel (arg) - 1 && any (arg(end) == "124")) arg_st.ghostscript.antialiasing_textalphabits = str2num (arg(end)); else error ("print: improper syntax, or value, for TextAlphaBits"); endif elseif (strncmpi (arg, "-graphicsalphabits=", 19)) n = find (arg == "="); - if (! isempty (n) && n == numel (arg) - 1 && ismember (arg(end), "124")) + if (! isempty (n) && n == numel (arg) - 1 && any (arg(end) == "124")) arg_st.ghostscript.antialiasing_graphicsalphabits = str2num (arg(end)); else error ("print: improper syntax, or value, for GraphicsAlphaBits");
--- a/scripts/plot/private/__quiver__.m +++ b/scripts/plot/private/__quiver__.m @@ -81,14 +81,14 @@ args = {}; while (ioff <= nargin) arg = varargin{ioff++}; - if (ischar (arg) && strncmpi (arg, "filled", 6)) + if (ischar (arg) && strcmpi (arg, "filled")) have_filled = true; elseif ((ischar (arg) || iscell (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("quiver", arg, false); if (valid) have_line_spec = true; - if (strncmp (linespec.linestyle, "none", 4)) + if (strcmp (linespec.linestyle, "none")) linespec.linestyle = "-"; endif else @@ -228,7 +228,7 @@ if (have_line_spec) if (isfield (linespec, "marker") - && ! strncmp (linespec.marker, "none", 4)) + && ! strcmp (linespec.marker, "none")) if (is3d) h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:), @@ -266,7 +266,7 @@ if (! have_line_spec || (isfield (linespec, "marker") - && strncmp (linespec.marker, "none", 4))) + && strcmp (linespec.marker, "none"))) if (is3d) h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none", "parent", hg);
--- a/scripts/plot/private/__scatter__.m +++ b/scripts/plot/private/__scatter__.m @@ -23,37 +23,21 @@ function hg = __scatter__ (varargin) - h = varargin{1}; - nd = varargin{2}; + hax = varargin{1}; # We don't do anything with this. Could remove it. + nd = varargin{2}; fcn = varargin{3}; - x = varargin{4}(:); - y = varargin{5}(:); - istart = 6; + x = varargin{4}(:); + y = varargin{5}(:); - if (nd == 3) + if (nd == 2) + istart = 6; + else z = varargin{6}(:); - idx = isnan (x) | isnan (y) | isnan (z); - x (idx) = []; - y (idx) = []; - z (idx) = []; istart = 7; - else - idx = isnan (x) | isnan (y); - x (idx) = []; - y (idx) = []; - z = zeros (length (x), 0); endif - firstnonnumeric = Inf; - for i = istart:nargin - if (! isnumeric (varargin{i})) - firstnonnumeric = i; - break; - endif - endfor - if (istart <= nargin) - s = varargin{istart}; + s = varargin{istart}(:); if (isempty (s) || ischar (s)) s = 6; endif @@ -64,15 +48,36 @@ s = 6; endif + ## Remove NaNs + idx = isnan (x) | isnan (y) | isnan (s); + if (nd == 3) + idx |= isnan (z); + z(idx) = []; + endif + x(idx) = []; + y(idx) = []; + if (nd == 2) + z = zeros (length (x), 0); + endif + if (numel (s) > 1) + s(idx) = []; + endif + + firstnonnumeric = find (! cellfun ("isnumeric", varargin(istart:nargin)), 1); + if (isempty (firstnonnumeric)) + firstnonnumeric = Inf; + else + firstnonnumeric += istart - 1; + endif + if (istart <= nargin && firstnonnumeric > istart) c = varargin{istart}; - if (isvector (c)) - if (columns (c) != 3) - c = c(:); - endif + if (isvector (c) && columns (c) != 3) + c = c(:); endif + ## Compare only first 4 letters of "fill" as that is what Matlab uses. elseif (firstnonnumeric == istart && ischar (varargin{istart}) - && ! strcmpi (varargin{istart}, "filled")) + && ! strncmpi (varargin{istart}, "filled", 4)) c = varargin{istart}; firstnonnumeric++; else @@ -86,18 +91,18 @@ iarg = firstnonnumeric; while (iarg <= nargin) arg = varargin{iarg++}; - if (ischar (arg) && strncmpi (arg, "filled", 6)) + if (ischar (arg) && strncmpi (arg, "filled", 4)) filled = true; elseif ((ischar (arg) || iscell (arg)) && ! have_marker) [linespec, valid] = __pltopt__ (fcn, arg, false); if (valid) have_marker = true; marker = linespec.marker; - if (strncmp (marker, "none", 4)) + if (strcmp (marker, "none")) marker = "o"; elseif (isempty (marker)) have_marker = false; - [dummy, marker] = __next_line_style__ (); + [~, marker] = __next_line_style__ (); endif else error ("%s: invalid linespec", fcn); @@ -116,13 +121,14 @@ hg = hggroup (); newargs = __add_datasource__ (fcn, hg, {"x", "y", "z", "c", "size"}, - newargs{:}); + newargs{:}); addproperty ("xdata", hg, "data", x); addproperty ("ydata", hg, "data", y); addproperty ("zdata", hg, "data", z); if (ischar (c)) - addproperty ("cdata", hg, "data", __color_str_rgb__ (c)); + ## For single explicit color, cdata is unused + addproperty ("cdata", hg, "data", []); else addproperty ("cdata", hg, "data", c); endif @@ -146,45 +152,44 @@ if (one_explicit_color) for i = 1 : numel (x) if (filled) - h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), - "faces", 1, "vertices", [x(i), y(i), z(i,:)], - "facecolor", "none", "edgecolor", "none", - "marker", marker, "markersize", s(i), - "markeredgecolor", c, "markerfacecolor", c, - "linestyle", "none"); + __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), + "faces", 1, "vertices", [x(i), y(i), z(i,:)], + "facecolor", "none", "edgecolor", "none", + "marker", marker, "markersize", s(i), + "markeredgecolor", c, "markerfacecolor", c, + "linestyle", "none"); else - h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), - "faces", 1, "vertices", [x(i), y(i), z(i,:)], - "facecolor", "none", "edgecolor", "none", - "marker", marker, "markersize", s(i), - "markeredgecolor", c, "markerfacecolor", "none", - "linestyle", "none"); + __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), + "faces", 1, "vertices", [x(i), y(i), z(i,:)], + "facecolor", "none", "edgecolor", "none", + "marker", marker, "markersize", s(i), + "markeredgecolor", c, "markerfacecolor", "none", + "linestyle", "none"); endif endfor else if (rows (c) == 1) - c = ones (rows (x), 1) * c; + c = repmat (c, rows (x), 1); endif for i = 1 : numel (x) if (filled) - h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), - "faces", 1, "vertices", [x(i), y(i), z(i,:)], - "facecolor", "none", "edgecolor", "none", - "marker", marker, "markersize", s(i), - "markeredgecolor", "none", - "markerfacecolor", "flat", - "cdata", c(i,:), "facevertexcdata", c(i,:), - "linestyle", "none"); + __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), + "faces", 1, "vertices", [x(i), y(i), z(i,:)], + "facecolor", "none", "edgecolor", "none", + "marker", marker, "markersize", s(i), + "markeredgecolor", "none", + "markerfacecolor", "flat", + "cdata", c(i,:), "facevertexcdata", c(i,:), + "linestyle", "none"); else - h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), - "faces", 1, "vertices", [x(i), y(i), z(i,:)], - "facecolor", "none", "edgecolor", "none", - "marker", marker, "markersize", s(i), - "markeredgecolor", "flat", - "markerfacecolor", "none", - "cdata", c(i,:), "facevertexcdata", c(i,:), - "linestyle", "none"); - + __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), + "faces", 1, "vertices", [x(i), y(i), z(i,:)], + "facecolor", "none", "edgecolor", "none", + "marker", marker, "markersize", s(i), + "markeredgecolor", "flat", + "markerfacecolor", "none", + "cdata", c(i,:), "facevertexcdata", c(i,:), + "linestyle", "none"); endif endfor endif @@ -195,23 +200,23 @@ vert = [x, y, z]; if (one_explicit_color) - h = render_size_color (hg, vert, s, c, marker, filled, true); + render_size_color (hg, vert, s, c, marker, filled, true); else if (rows (c) == 1) - c = ones (rows (x), 1) * c; + c = repmat (c, rows (x), 1); endif - ## We want to group points by colour. So first get all the unique colours + ## We want to group points by color. So first get all the unique colors [cc, ~, c_to_cc] = unique (c, "rows"); - for i = 1:rows (cc) - ## Now for each possible unique colour, get the logical index of - ## points that correspond to that colour + for i = 1 : rows (cc) + ## Now for each possible unique color, get the logical index of + ## points that correspond to that color idx = (i == c_to_cc); if (isscalar (s)) - h = render_size_color (hg, vert(idx, :), s, c(idx,:), + render_size_color (hg, vert(idx, :), s, c(idx,:), marker, filled, true); else - h = render_size_color (hg, vert(idx, :), s(idx), c(idx,:), + render_size_color (hg, vert(idx, :), s(idx), c(idx,:), marker, filled, true); endif endfor @@ -259,20 +264,20 @@ endfunction -function h = render_size_color (hg, vert, s, c, marker, filled, isflat) +function render_size_color (hg, vert, s, c, marker, filled, isflat) if (isscalar (s)) x = vert(:,1); y = vert(:,2); z = vert(:,3:end); toolkit = get (ancestor (hg, "figure"), "__graphics_toolkit__"); ## Does gnuplot only support triangles with different vertex colors ? - ## TODO - Verify gnuplot can only support one color. If RGB triplets - ## can be assigned to each vertex, then fix __go_draw_axe__.m + ## TODO: Verify gnuplot can only support one color. If RGB triplets + ## can be assigned to each vertex, then fix __go_draw_axes__.m gnuplot_hack = (numel (x) > 1 && columns (c) == 3 && strcmp (toolkit, "gnuplot")); if (ischar (c) || ! isflat || gnuplot_hack) if (filled) - h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, + __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, @@ -280,7 +285,7 @@ "markerfacecolor", c(1,:), "markersize", s, "linestyle", "none"); else - h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, + __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, @@ -290,7 +295,7 @@ endif else if (filled) - h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, + __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markersize", s, @@ -299,7 +304,7 @@ "cdata", c, "facevertexcdata", c, "linestyle", "none"); else - h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, + __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markersize", s, @@ -310,11 +315,11 @@ endif endif else - ## FIXME: round the size to one decimal place. It's not quite right, though. + ## Round size to one decimal place. [ss, ~, s_to_ss] = unique (ceil (s*10) / 10); for i = 1:rows (ss) idx = (i == s_to_ss); - h = render_size_color (hg, vert(idx,:), ss(i), c, + render_size_color (hg, vert(idx,:), ss(i), c, marker, filled, isflat); endfor endif @@ -322,58 +327,44 @@ function update_props (h, d) lw = get (h, "linewidth"); - m = get (h, "marker"); + m = get (h, "marker"); fc = get (h, "markerfacecolor"); ec = get (h, "markeredgecolor"); kids = get (h, "children"); - for i = 1 : numel (kids) - set (kids (i), "linewidth", lw, "marker", m, "markerfacecolor", fc, - "edgecolor", ec); - endfor + set (kids, "linewidth", lw, "marker", m, + "markerfacecolor", fc, "markeredgecolor", ec); endfunction function update_data (h, d) - x1 = get (h, "xdata"); - y1 = get (h, "ydata"); - z1 = get (h, "zdata"); - c1 = get (h, "cdata"); - if (!ischar (c1) && rows (c1) == 1) - c1 = repmat (c1, numel (x1), 1); + x = get (h, "xdata"); + y = get (h, "ydata"); + z = get (h, "zdata"); + c = get (h, "cdata"); + if (rows (c) == 1) + c = repmat (c, numel (x), 1); endif - size1 = get (h, "sizedata"); - if (numel (size1) == 1) - size1 = repmat (size1, numel (x1), 1); + s = get (h, "sizedata"); + if (numel (s) == 1) + s = repmat (s, numel (x), 1); endif hlist = get (h, "children"); - if (ischar (c1)) - if (isempty (z1)) - for i = 1 : length (hlist) - set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", c1, - "markersize", size1(i)); - endfor - else - for i = 1 : length (hlist) - set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", c1, - "markersize", size1(i)); - endfor - endif + + if (isempty (z)) + for i = 1 : length (hlist) + set (hlist(i), "vertices", [x(i), y(i)], + "cdata", reshape (c(i,:),[1, size(c)(2:end)]), + "facevertexcdata", c(i,:), + "markersize", s(i)); + endfor else - if (isempty (z1)) - for i = 1 : length (hlist) - set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", - reshape (c1(i,:),[1, size(c1)(2:end)]), - "facevertexcdata", c1(i,:), - "markersize", size1(i)); - endfor - else - for i = 1 : length (hlist) - set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", - reshape (c1(i,:),[1, size(c1)(2:end)]), - "facevertexcdata", c1(i,:), - "markersize", size1(i)); - endfor - endif + for i = 1 : length (hlist) + set (hlist(i), "vertices", [x(i), y(i), z(i)], + "cdata", reshape (cd(i,:),[1, size(cd)(2:end)]), + "facevertexcdata", cd(i,:), + "markersize", s(i)); + endfor endif + endfunction
--- a/scripts/plot/private/__tight_eps_bbox__.m +++ b/scripts/plot/private/__tight_eps_bbox__.m @@ -58,7 +58,7 @@ looking_for_bbox = true; while (looking_for_bbox) current_line = fgetl (fid); - if (strncmpi (current_line, box_string, numel (box_string))) + if (strncmpi (current_line, box_string, length (box_string))) line_length = numel (current_line); num_spaces = line_length - numel (tight_bbox_line); if (numel (current_line) >= numel (tight_bbox_line))
--- a/scripts/plot/scatter.m +++ b/scripts/plot/scatter.m @@ -74,21 +74,21 @@ if (nargin < 2) print_usage (); - else + endif + oldfig = []; if (! isempty (hax)) oldfig = get (0, "currentfigure"); endif - unwind_protect - hax = newplot (hax); - - htmp = __scatter__ (hax, 2, "scatter", varargin{:}); - unwind_protect_cleanup + unwind_protect + hax = newplot (hax); + + htmp = __scatter__ (hax, 2, "scatter", varargin{:}); + unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); endif - end_unwind_protect - endif + end_unwind_protect if (nargout > 0) retval = htmp;
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -71,29 +71,29 @@ if (nargin < 2) print_usage (); - else + endif + oldfig = []; if (! isempty (hax)) oldfig = get (0, "currentfigure"); endif - unwind_protect - hax = newplot (hax); - - tmp = __scatter__ (hax, 3, "scatter3", varargin{:}); + unwind_protect + hax = newplot (hax); + + htmp = __scatter__ (hax, 3, "scatter3", varargin{:}); - if (! ishold (hax)) - set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); - endif - unwind_protect_cleanup - if (! isempty (oldfig)) - set (0, "currentfigure", oldfig); - endif - end_unwind_protect - endif + if (! ishold (hax)) + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); + endif + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect if (nargout > 0) - retval = tmp; + retval = htmp; endif endfunction
--- a/scripts/plot/uigetfile.m +++ b/scripts/plot/uigetfile.m @@ -103,9 +103,9 @@ val = varargin{i}; if (ischar (val)) val = tolower (val); - if (strncmp (val, "multiselect", 11)) + if (strcmp (val, "multiselect")) idx1 = i; - elseif (strncmp (val, "position", 8)) + elseif (strcmp (val, "position")) idx2 = i; endif endif @@ -168,13 +168,13 @@ for i = stridx : 2 : nargin prop = varargin{i}; val = varargin{i + 1}; - if (strncmp (tolower (prop), "position", 8)) + if (strcmpi (prop, "position")) if (ismatrix (val) && length (val) == 2) outargs{4} = val; else error ("uigetfile: expecting 2-element vector for position argument"); endif - elseif (strncmp (tolower (prop), "multiselect", 11)) + elseif (strcmpi (prop, "multiselect")) if (ischar (val)) outargs{5} = tolower (val); else
--- a/scripts/statistics/distributions/geocdf.m +++ b/scripts/statistics/distributions/geocdf.m @@ -21,6 +21,9 @@ ## @deftypefn {Function File} {} geocdf (@var{x}, @var{p}) ## For each element of @var{x}, compute the cumulative distribution function ## (CDF) at @var{x} of the geometric distribution with parameter @var{p}. +## +## The geometric distribution models the number of failures (@var{x}-1) of a +## Bernoulli trial with probability @var{p} before the first success (@var{x}). ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
--- a/scripts/statistics/distributions/geoinv.m +++ b/scripts/statistics/distributions/geoinv.m @@ -21,6 +21,9 @@ ## @deftypefn {Function File} {} geoinv (@var{x}, @var{p}) ## For each element of @var{x}, compute the quantile (the inverse of ## the CDF) at @var{x} of the geometric distribution with parameter @var{p}. +## +## The geometric distribution models the number of failures (@var{x}-1) of a +## Bernoulli trial with probability @var{p} before the first success (@var{x}). ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
--- a/scripts/statistics/distributions/geopdf.m +++ b/scripts/statistics/distributions/geopdf.m @@ -21,6 +21,9 @@ ## @deftypefn {Function File} {} geopdf (@var{x}, @var{p}) ## For each element of @var{x}, compute the probability density function ## (PDF) at @var{x} of the geometric distribution with parameter @var{p}. +## +## The geometric distribution models the number of failures (@var{x}-1) of a +## Bernoulli trial with probability @var{p} before the first success (@var{x}). ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
--- a/scripts/statistics/distributions/geornd.m +++ b/scripts/statistics/distributions/geornd.m @@ -33,6 +33,9 @@ ## ## If no size arguments are given then the result matrix is the size of ## @var{p}. +## +## The geometric distribution models the number of failures (@var{x}-1) of a +## Bernoulli trial with probability @var{p} before the first success (@var{x}). ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
--- a/scripts/strings/strsplit.m +++ b/scripts/strings/strsplit.m @@ -160,7 +160,7 @@ endif ## Save the length of the "delimitertype" parameter - length_deltype = numel (args.delimitertype); + length_deltype = length (args.delimitertype); if (nargin == 1 || (nargin > 1 && (islogical (del) || isnumeric (del)))) if (nargin > 1) @@ -168,7 +168,7 @@ args.collapsedelimiters = del; endif ## Set proper default for the delimiter type - if (strncmpi (args.delimitertype, "simple", numel (args.delimitertype))) + if (strncmpi (args.delimitertype, "simple", length (args.delimitertype))) del = {" ","\f","\n","\r","\t","\v"}; else del = "\\s";
--- a/scripts/strings/validatestring.m +++ b/scripts/strings/validatestring.m @@ -52,7 +52,7 @@ ## blue, black ## @end group ## @end smallexample -## +## ## @seealso{strcmp, strcmpi} ## @end deftypefn @@ -70,7 +70,7 @@ position = varargin{end}; varargin(end) = []; endif - + funcname = varname = ""; char_idx = cellfun ("isclass", varargin, "char"); n_chararg = sum (char_idx); @@ -112,7 +112,7 @@ errstr(end:end+1) = ":\n"; endif - matches = strncmpi (str, strarray(:), numel (str)); + matches = strncmpi (str, strarray(:), length (str)); nmatches = sum (matches); if (nmatches == 0) error ("validatestring: %s'%s' does not match any of\n%s", errstr, str, @@ -124,9 +124,9 @@ ## If true, choose the shortest. If not, raise an error. match_idx = find (matches); match_len = cellfun ("length", strarray(match_idx)); - [min_len, min_idx] = min (match_len); + [min_len, min_idx] = min (match_len); short_str = strarray{match_idx(min_idx)}; - submatch = strncmpi (short_str, strarray(match_idx), min_len); + submatch = strncmpi (short_str, strarray(match_idx), min_len); if (all (submatch)) str = short_str; else