Mercurial > octave
changeset 22689:a3e4c8fb69cb
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 27 Oct 2016 22:13:53 -0400 |
parents | 340e37fd3c20 (diff) 9a0265ead11c (current diff) |
children | b4c5fbaa96a8 |
files | configure.ac scripts/ode/odeplot.m |
diffstat | 64 files changed, 1824 insertions(+), 2415 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Thu Oct 27 22:02:40 2016 -0400 +++ b/NEWS Thu Oct 27 22:13:53 2016 -0400 @@ -1,3 +1,45 @@ +Summary of important user-visible changes for version 4.4: +--------------------------------------------------------- + + ** Other new functions added in 4.4: + + gsvd + + ** Deprecated functions. + + The following functions have been deprecated in Octave 4.4 and will + be removed from Octave 4.8 (or whatever version is the second major + release after 4.4): + + Function | Replacement + ---------------------|------------------ + + + ** The following functions were deprecated in Octave 4.0 and have been + removed from Octave 4.4. + + allow_noninteger_range_as_index + bicubic + delaunay3 + do_braindead_shortcircuit_evaluation + dump_prefs + find_dir_in_path + finite + fmod + fnmatch + gmap40 + loadaudio + luinc + mouse_wheel_zoom + nfields + octave_tmp_file_name + playaudio + saveaudio + setaudio + syl + usage + + Summary of important user-visible changes for version 4.2: ---------------------------------------------------------
--- a/configure.ac Thu Oct 27 22:02:40 2016 -0400 +++ b/configure.ac Thu Oct 27 22:13:53 2016 -0400 @@ -19,14 +19,14 @@ ### <http://www.gnu.org/licenses/>. AC_PREREQ([2.63]) -AC_INIT([GNU Octave], [4.2.0-rc3], [http://octave.org/bugs.html], [octave]) +AC_INIT([GNU Octave], [4.3.0+], [http://octave.org/bugs.html], [octave]) dnl Note that the version number is duplicated here and in AC_INIT dnl because AC_INIT requires it to be static, not computed from dnl shell variables. OCTAVE_MAJOR_VERSION=4 -OCTAVE_MINOR_VERSION=2 -OCTAVE_PATCH_VERSION=0-rc3 +OCTAVE_MINOR_VERSION=3 +OCTAVE_PATCH_VERSION=0+ dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION"
--- a/doc/interpreter/expr.txi Thu Oct 27 22:02:40 2016 -0400 +++ b/doc/interpreter/expr.txi Thu Oct 27 22:13:53 2016 -0400 @@ -319,8 +319,6 @@ @DOCSTRING(isindex) -@DOCSTRING(allow_noninteger_range_as_index) - @node Calling Functions @section Calling Functions @@ -1009,12 +1007,10 @@ @sc{matlab} has special behavior that allows the operators @samp{&} and @samp{|} to short-circuit when used in the truth expression for @code{if} and -@code{while} statements. Octave also behaves the same way by default, -though the use of the @samp{&} and @samp{|} operators in this way is -strongly discouraged. Instead, you should use the @samp{&&} and @samp{||} -operators that always have short-circuit behavior. - -@DOCSTRING(do_braindead_shortcircuit_evaluation) +@code{while} statements. Octave behaves the same way for compatibility, +however, the use of the @samp{&} and @samp{|} operators in this way is +strongly discouraged and a warning will be issued. Instead, you should use +the @samp{&&} and @samp{||} operators that always have short-circuit behavior. Finally, the ternary operator (?:) is not supported in Octave. If short-circuiting is not important, it can be replaced by the @code{ifelse}
--- a/doc/interpreter/grammar.txi Thu Oct 27 22:02:40 2016 -0400 +++ b/doc/interpreter/grammar.txi Thu Oct 27 22:13:53 2016 -0400 @@ -64,8 +64,7 @@ The parser has a number of variables that affect its internal operation. These variables are generally documented in the manual alongside the code that -they affect. For example, @code{allow_noninteger_range_as_index} is discussed -in the section on index expressions. +they affect. In addition, there are three non-specific parser customization functions. @code{add_input_event_hook} can be used to schedule a user function for
--- a/doc/interpreter/linalg.txi Thu Oct 27 22:02:40 2016 -0400 +++ b/doc/interpreter/linalg.txi Thu Oct 27 22:13:53 2016 -0400 @@ -108,6 +108,8 @@ @DOCSTRING(givens) +@DOCSTRING(gsvd) + @DOCSTRING(planerot) @DOCSTRING(inv)
--- a/doc/interpreter/plot.txi Thu Oct 27 22:02:40 2016 -0400 +++ b/doc/interpreter/plot.txi Thu Oct 27 22:13:53 2016 -0400 @@ -1137,31 +1137,34 @@ get (h, ""); error: get: ambiguous figure property name ; possible matches: -__enhanced__ hittest resize -__graphics_toolkit__ integerhandle resizefcn -__guidata__ interruptible selected -__modified__ inverthardcopy selectionhighlight -__myhandle__ keypressfcn selectiontype -__plot_stream__ keyreleasefcn tag -alphamap menubar toolbar -beingdeleted mincolormap type -busyaction name uicontextmenu -buttondownfcn nextplot units -children numbertitle userdata -clipping outerposition visible -closerequestfcn paperorientation windowbuttondownfcn -color paperposition windowbuttonmotionfcn -colormap paperpositionmode windowbuttonupfcn -createfcn papersize windowkeypressfcn -currentaxes papertype windowkeyreleasefcn -currentcharacter paperunits windowscrollwheelfcn -currentobject parent windowstyle -currentpoint pointer wvisual -deletefcn pointershapecdata wvisualmode -dockcontrols pointershapehotspot xdisplay -doublebuffer position xvisual -filename renderer xvisualmode -handlevisibility renderermode +__gl_extensions__ dockcontrols renderer +__gl_renderer__ doublebuffer renderermode +__gl_vendor__ filename resize +__gl_version__ graphicssmoothing resizefcn +__graphics_toolkit__ handlevisibility selected +__guidata__ hittest selectionhighlight +__modified__ integerhandle selectiontype +__mouse_mode__ interruptible sizechangedfcn +__myhandle__ inverthardcopy tag +__pan_mode__ keypressfcn toolbar +__plot_stream__ keyreleasefcn type +__rotate_mode__ menubar uicontextmenu +__zoom_mode__ mincolormap units +alphamap name userdata +beingdeleted nextplot visible +busyaction numbertitle windowbuttondownfcn +buttondownfcn outerposition windowbuttonmotionfcn +children paperorientation windowbuttonupfcn +clipping paperposition windowkeypressfcn +closerequestfcn paperpositionmode windowkeyreleasefcn +color papersize windowscrollwheelfcn +colormap papertype windowstyle +createfcn paperunits wvisual +currentaxes parent wvisualmode +currentcharacter pointer xdisplay +currentobject pointershapecdata xvisual +currentpoint pointershapehotspot xvisualmode +deletefcn position @end smallexample The root figure has index 0. Its properties may be displayed by:
--- a/libgui/graphics/KeyMap.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libgui/graphics/KeyMap.cc Thu Oct 27 22:13:53 2016 -0400 @@ -113,7 +113,6 @@ keyMapper[Qt::Key_Direction_L] = "direction_l"; keyMapper[Qt::Key_Direction_R] = "direction_r"; keyMapper[Qt::Key_Space] = "space"; - keyMapper[Qt::Key_Any] = "any"; keyMapper[Qt::Key_Exclam] = "exclam"; keyMapper[Qt::Key_QuoteDbl] = "quotedbl"; keyMapper[Qt::Key_NumberSign] = "numbersign";
--- a/libgui/graphics/QtHandlesUtils.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libgui/graphics/QtHandlesUtils.cc Thu Oct 27 22:13:53 2016 -0400 @@ -124,7 +124,7 @@ mapsInitialized = true; } - f.setPointSizeF (props.get_fontsize_points (height)); + f.setPointSizeF (props.get___fontsize_points__ (height)); f.setWeight (weightMap[props.get_fontweight ()]); f.setStyle (angleMap[props.get_fontangle ()]);
--- a/libinterp/corefcn/__dispatch__.cc Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - -Copyright (C) 2001-2016 John W. Eaton and Paul Kienzle - -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/>. - -*/ - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include <list> -#include <map> -#include <string> - -#include "Cell.h" -#include "oct-map.h" -#include "defun.h" -#include "ov.h" -#include "ov-fcn.h" -#include "ov-typeinfo.h" -#include "pager.h" -#include "parse.h" -#include "symtab.h" -#include "variables.h" - -DEFUN (__dispatch__, args, nargout, - doc: /* -*- texinfo -*- -@deftypefn {} {} __dispatch__ () -Undocumented internal function. -@end deftypefn */) -{ - int nargin = args.length (); - - if (nargin < 1 || nargin > 3) - print_usage (); - - std::string f, r, t; - - f = args(0).xstring_value ("__dispatch__: first argument must be a function name"); - - if (nargin > 1) - r = args(1).xstring_value ("__dispatch__: second argument must be a function name"); - - if (nargin > 2) - t = args(2).xstring_value ("__dispatch__: third argument must be a type name"); - - octave_value retval; - - if (nargin == 1) - { - if (nargout > 0) - { - symbol_table::fcn_info::dispatch_map_type dm - = symbol_table::get_dispatch (f); - - size_t len = dm.size (); - - Cell type_field (len, 1); - Cell name_field (len, 1); - - symbol_table::fcn_info::dispatch_map_type::const_iterator p - = dm.begin (); - - for (size_t i = 0; i < len; i++) - { - type_field(i) = p->first; - name_field(i) = p->second; - - p++; - } - - octave_scalar_map m; - - m.assign ("type", type_field); - m.assign ("name", name_field); - - retval = m; - } - else - symbol_table::print_dispatch (octave_stdout, f); - } - else if (nargin == 2) - { - t = r; - symbol_table::clear_dispatch (f, t); - } - else - symbol_table::add_dispatch (f, t, r); - - return retval; -} - -/* -## No test needed for internal helper function. -%!assert (1) -*/ -
--- a/libinterp/corefcn/data.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/data.cc Thu Oct 27 22:13:53 2016 -0400 @@ -3549,6 +3549,49 @@ return retval; } +/* +%!error <undefined> 1+Infj +%!error <undefined> 1+Infi + +%!test <31974> +%! assert (Inf + Inf*i, complex (Inf, Inf)) +%! +%! assert (1 + Inf*i, complex (1, Inf)) +%! assert (1 + Inf*j, complex (1, Inf)) +%! +%! ## whitespace should not affect parsing +%! assert (1+Inf*i, complex (1, Inf)) +%! assert (1+Inf*j, complex (1, Inf)) +%! +%! assert (NaN*j, complex (0, NaN)) +%! +%! assert (Inf * 4j, complex (0, Inf)) + +%!test <31974> +%! x = Inf; +%! assert (x * j, complex (0, Inf)) +%! j = complex (0, 1); +%! assert (Inf * j, complex (0, Inf)) + +%!test <31974> +%! exp = complex (zeros (2, 2), Inf (2, 2)); +%! assert (Inf (2, 2) * j, exp) +%! assert (Inf (2, 2) .* j, exp) +%! assert (Inf * (ones (2, 2) * j), exp) +%! assert (Inf (2, 2) .* (ones (2, 2) * j), exp) + +%!test <31974> +%! assert ([Inf; 0] * [i, 0], complex ([NaN NaN; 0 0], [Inf NaN; 0 0])) +%! assert ([Inf, 0] * [i; 0], complex (NaN, Inf)) +%! assert ([Inf, 0] .* [i, 0], complex ([0 0], [Inf 0])) + +%!test <31974> +%! m = @(x, y) x * y; +%! d = @(x, y) x / y; +%! assert (m (Inf, i), complex (0, +Inf)) +%! assert (d (Inf, i), complex (0, -Inf)) +*/ + DEFUN (isreal, args, , doc: /* -*- texinfo -*- @deftypefn {} {} isreal (@var{x})
--- a/libinterp/corefcn/dlmread.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/dlmread.cc Thu Oct 27 22:13:53 2016 -0400 @@ -272,42 +272,47 @@ octave_idx_type j = 0; octave_idx_type r = 1; octave_idx_type c = 1; - octave_idx_type rmax = 0; + // Start with a reasonable size to avoid constant resizing of matrix. + octave_idx_type rmax = 32; octave_idx_type cmax = 0; - Matrix rdata; + Matrix rdata (rmax, cmax, empty_value); ComplexMatrix cdata; bool iscmplx = false; - bool sepflag = false; + bool sep_is_wspace = (sep.find_first_of (" \t") != std::string::npos); + bool auto_sep_is_wspace = false; std::string line; - // Skip the r0 leading lines as these might be a header. + // Skip the r0 leading lines (header) for (octave_idx_type m = 0; m < r0; m++) getline (*input, line); r1 -= r0; std::istringstream tmp_stream; - // Read in the data one field at a time, growing the data matrix - // as needed. + // Read the data one field at a time, growing the data matrix as needed. while (getline (*input, line)) { // Skip blank lines for compatibility. - if (line.find_first_not_of (" \t") == std::string::npos) + if ((! sep_is_wspace || auto_sep_is_wspace) + && line.find_first_not_of (" \t") == std::string::npos) continue; - // To be compatible with matlab, blank separator should - // correspond to whitespace as delimter. - if (! sep.length ()) + // Infer separator from file if delimiter is blank. + if (sep.empty ()) { - size_t n = line.find_first_of (",:; \t", - line.find_first_of ("0123456789")); + // Skip leading whitespace. + size_t pos1 = line.find_first_not_of (" \t"); + + // For Matlab compatibility, blank delimiter should + // correspond to whitespace (space and tab). + size_t n = line.find_first_of (",:; \t", pos1); if (n == std::string::npos) { sep = " \t"; - sepflag = true; + auto_sep_is_wspace = true; } else { @@ -317,8 +322,8 @@ { case ' ': case '\t': - sepflag = true; sep = " \t"; + auto_sep_is_wspace = true; break; default: @@ -328,67 +333,84 @@ } } + // Estimate the number of columns from first line of data. if (cmax == 0) { - // Try to estimate the number of columns. Skip leading - // whitespace. - size_t pos1 = line.find_first_not_of (" \t"); + size_t pos1, pos2; + if (auto_sep_is_wspace) + pos1 = line.find_first_not_of (" \t"); + else + pos1 = 0; + do { - size_t pos2 = line.find_first_of (sep, pos1); + pos2 = line.find_first_of (sep, pos1); - if (sepflag && pos2 != std::string::npos) - // Treat consecutive separators as one. + if (auto_sep_is_wspace && pos2 != std::string::npos) { + // Treat consecutive separators as one. pos2 = line.find_first_not_of (sep, pos2); if (pos2 != std::string::npos) pos2 -= 1; - else - pos2 = line.length () - 1; } - cmax++; - + // Separator followed by EOL doesn't generate extra column if (pos2 != std::string::npos) - pos1 = pos2 + 1; - else - pos1 = std::string::npos; + cmax++; + pos1 = pos2 + 1; } - while (pos1 != std::string::npos); + while (pos2 != std::string::npos); + // FIXME: Should always be the case that iscmplx == false. + // Flag is initialized that way and no data has been read. if (iscmplx) - cdata.resize (rmax, cmax); + cdata.resize (rmax, cmax, empty_value); else - rdata.resize (rmax, cmax); + rdata.resize (rmax, cmax, empty_value); } r = (r > i + 1 ? r : i + 1); j = 0; - // Skip leading whitespace. - size_t pos1 = line.find_first_not_of (" \t"); + + size_t pos1, pos2; + if (auto_sep_is_wspace) + pos1 = line.find_first_not_of (" \t"); // Skip leading whitespace. + else + pos1 = 0; + do { octave_quit (); - size_t pos2 = line.find_first_of (sep, pos1); + pos2 = line.find_first_of (sep, pos1); std::string str = line.substr (pos1, pos2 - pos1); - if (sepflag && pos2 != std::string::npos) - // Treat consecutive separators as one. - pos2 = line.find_first_not_of (sep, pos2) - 1; + if (auto_sep_is_wspace && pos2 != std::string::npos) + { + // Treat consecutive separators as one. + pos2 = line.find_first_not_of (sep, pos2); + if (pos2 != std::string::npos) + pos2 -= 1; + else + pos2 = line.length () - 1; + } + + // Separator followed by EOL doesn't generate extra column + if (pos2 == std::string::npos && str.empty ()) + break; c = (c > j + 1 ? c : j + 1); if (r > rmax || c > cmax) { - // Use resize_and_fill for the case of not-equal - // length rows. - rmax = 2*r; - cmax = c; + // Use resize_and_fill for the case of unequal length rows. + // Keep rmax a power of 2. + rmax = 2 * std::max (r-1, static_cast<octave_idx_type> (1)); + cmax = std::max (c, cmax); if (iscmplx) - cdata.resize (rmax, cmax); + cdata.resize (rmax, cmax, empty_value); else - rdata.resize (rmax, cmax); + rdata.resize (rmax, cmax, empty_value); } tmp_stream.str (str); @@ -433,13 +455,9 @@ else rdata(i,j++) = empty_value; - if (pos2 != std::string::npos) - pos1 = pos2 + 1; - else - pos1 = std::string::npos; - + pos1 = pos2 + 1; } - while (pos1 != std::string::npos); + while (pos2 != std::string::npos); if (i == r1) break; @@ -468,42 +486,61 @@ } /* -%!shared file +%!test %! file = tempname (); -%! fid = fopen (file, "wt"); -%! fwrite (fid, "1, 2, 3\n4, 5, 6\n7, 8, 9\n10, 11, 12"); -%! fclose (fid); - -%!assert (dlmread (file), [1, 2, 3; 4, 5, 6; 7, 8, 9;10, 11, 12]) -%!assert (dlmread (file, ","), [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]) -%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4, 5; 7, 8]) -%!assert (dlmread (file, ",", "B1..C2"), [2, 3; 5, 6]) -%!assert (dlmread (file, ",", "B1:C2"), [2, 3; 5, 6]) -%!assert (dlmread (file, ",", "..C2"), [1, 2, 3; 4, 5, 6]) -%!assert (dlmread (file, ",", 0, 1), [2, 3; 5, 6; 8, 9; 11, 12]) -%!assert (dlmread (file, ",", "B1.."), [2, 3; 5, 6; 8, 9; 11, 12]) -%!error (dlmread (file, ",", [0 1])) +%! unwind_protect +%! fid = fopen (file, "wt"); +%! fwrite (fid, "1, 2, 3\n4, 5, 6\n7, 8, 9\n10, 11, 12"); +%! fclose (fid); +%! +%! assert (dlmread (file), [1, 2, 3; 4, 5, 6; 7, 8, 9;10, 11, 12]); +%! assert (dlmread (file, ","), [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]); +%! assert (dlmread (file, ",", [1, 0, 2, 1]), [4, 5; 7, 8]); +%! assert (dlmread (file, ",", "B1..C2"), [2, 3; 5, 6]); +%! assert (dlmread (file, ",", "B1:C2"), [2, 3; 5, 6]); +%! assert (dlmread (file, ",", "..C2"), [1, 2, 3; 4, 5, 6]); +%! assert (dlmread (file, ",", 0, 1), [2, 3; 5, 6; 8, 9; 11, 12]); +%! assert (dlmread (file, ",", "B1.."), [2, 3; 5, 6; 8, 9; 11, 12]); +%! fail ('dlmread (file, ",", [0 1])'); +%! unwind_protect_cleanup +%! unlink (file); +%! end_unwind_protect %!test -%! unlink (file); - -%!shared file %! file = tempname (); -%! fid = fopen (file, "wt"); -%! fwrite (fid, "1, 2, 3\n4+4i, 5, 6\n7, 8, 9\n10, 11, 12"); -%! fclose (fid); +%! unwind_protect +%! fid = fopen (file, "wt"); +%! fwrite (fid, "1, 2, 3\n4+4i, 5, 6\n7, 8, 9\n10, 11, 12"); +%! fclose (fid); +%! +%! assert (dlmread (file), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]); +%! assert (dlmread (file, ","), [1,2,3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]); +%! assert (dlmread (file, ",", [1, 0, 2, 1]), [4 + 4i, 5; 7, 8]); +%! assert (dlmread (file, ",", "A2..B3"), [4 + 4i, 5; 7, 8]); +%! assert (dlmread (file, ",", "A2:B3"), [4 + 4i, 5; 7, 8]); +%! assert (dlmread (file, ",", "..B3"), [1, 2; 4 + 4i, 5; 7, 8]); +%! assert (dlmread (file, ",", 1, 0), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]); +%! assert (dlmread (file, ",", "A2.."), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]); +%! fail ('dlmread (file, ",", [0 1])'); +%! unwind_protect_cleanup +%! unlink (file); +%! end_unwind_protect -%!assert (dlmread (file), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]) -%!assert (dlmread (file, ","), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]) -%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4 + 4i, 5; 7, 8]) -%!assert (dlmread (file, ",", "A2..B3"), [4 + 4i, 5; 7, 8]) -%!assert (dlmread (file, ",", "A2:B3"), [4 + 4i, 5; 7, 8]) -%!assert (dlmread (file, ",", "..B3"), [1, 2; 4 + 4i, 5; 7, 8]) -%!assert (dlmread (file, ",", 1, 0), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]) -%!assert (dlmread (file, ",", "A2.."), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]) -%!error (dlmread (file, ",", [0 1])) +%!test <42025> +%! file = tempname (); +%! unwind_protect +%! fid = fopen (file, "wt"); +%! fwrite (fid, " \n 1 2\n11 22\n "); +%! fclose (fid); +%! +%! assert (dlmread (file), [1, 2; 11, 22]); +%! assert (dlmread (file, " "), [ 0, 0, 0, 0 +%! 0, 1, 2, 0 +%! 11, 22, 0, 0 +%! 0, 0, 0, 0]); +%! unwind_protect_cleanup +%! unlink (file); +%! end_unwind_protect -%!test -%! unlink (file); */
--- a/libinterp/corefcn/gl-render.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/gl-render.cc Thu Oct 27 22:13:53 2016 -0400 @@ -1376,7 +1376,7 @@ && (minorgridstyle != "none")); bool do_xminortick = props.is_xminortick (); Matrix xticks = xform.xscale (props.get_xtick ().matrix_value ()); - Matrix xmticks = xform.xscale (props.get_xmtick ().matrix_value ()); + Matrix xmticks = xform.xscale (props.get_xminortickvalues ().matrix_value ()); string_vector xticklabels = props.get_xticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -1513,7 +1513,7 @@ && (minorgridstyle != "none")); bool do_yminortick = props.is_yminortick (); Matrix yticks = xform.yscale (props.get_ytick ().matrix_value ()); - Matrix ymticks = xform.yscale (props.get_ymtick ().matrix_value ()); + Matrix ymticks = xform.yscale (props.get_yminortickvalues ().matrix_value ()); string_vector yticklabels = props.get_yticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -1641,7 +1641,7 @@ && (minorgridstyle != "none")); bool do_zminortick = props.is_zminortick (); Matrix zticks = xform.zscale (props.get_ztick ().matrix_value ()); - Matrix zmticks = xform.zscale (props.get_zmtick ().matrix_value ()); + Matrix zmticks = xform.zscale (props.get_zminortickvalues ().matrix_value ()); string_vector zticklabels = props.get_zticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -3587,7 +3587,7 @@ txt_renderer.set_font (props.get ("fontname").string_value (), props.get ("fontweight").string_value (), props.get ("fontangle").string_value (), - props.get ("fontsize_points").double_value ()); + props.get ("__fontsize_points__").double_value ()); } void
--- a/libinterp/corefcn/gl2ps-print.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/gl2ps-print.cc Thu Oct 27 22:13:53 2016 -0400 @@ -678,7 +678,7 @@ if (props.has_property ("interpreter")) set_interpreter (props.get ("interpreter").string_value ()); - fontsize = props.get ("fontsize_points").double_value (); + fontsize = props.get ("__fontsize_points__").double_value (); caseless_str fn = props.get ("fontname").xtolower ().string_value (); bool isbold =
--- a/libinterp/corefcn/graphics.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/graphics.cc Thu Oct 27 22:13:53 2016 -0400 @@ -4552,10 +4552,10 @@ xset (zlabel.handle_value (), "clipping", "off"); xset (title.handle_value (), "clipping", "off"); - xset (xlabel.handle_value (), "autopos_tag", "xlabel"); - xset (ylabel.handle_value (), "autopos_tag", "ylabel"); - xset (zlabel.handle_value (), "autopos_tag", "zlabel"); - xset (title.handle_value (), "autopos_tag", "title"); + xset (xlabel.handle_value (), "__autopos_tag__", "xlabel"); + xset (ylabel.handle_value (), "__autopos_tag__", "ylabel"); + xset (zlabel.handle_value (), "__autopos_tag__", "zlabel"); + xset (title.handle_value (), "__autopos_tag__", "title"); adopt (xlabel.handle_value ()); adopt (ylabel.handle_value ()); @@ -4743,7 +4743,7 @@ xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); xset (xlabel.handle_value (), "clipping", "off"); xset (xlabel.handle_value (), "color", get_xcolor ()); - xset (xlabel.handle_value (), "autopos_tag", "xlabel"); + xset (xlabel.handle_value (), "__autopos_tag__", "xlabel"); update_xlabel_position (); } @@ -4757,7 +4757,7 @@ xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); xset (ylabel.handle_value (), "clipping", "off"); xset (ylabel.handle_value (), "color", get_ycolor ()); - xset (ylabel.handle_value (), "autopos_tag", "ylabel"); + xset (ylabel.handle_value (), "__autopos_tag__", "ylabel"); update_ylabel_position (); } @@ -4771,7 +4771,7 @@ xset (zlabel.handle_value (), "verticalalignmentmode", "auto"); xset (zlabel.handle_value (), "clipping", "off"); xset (zlabel.handle_value (), "color", get_zcolor ()); - xset (zlabel.handle_value (), "autopos_tag", "zlabel"); + xset (zlabel.handle_value (), "__autopos_tag__", "zlabel"); update_zlabel_position (); } @@ -4785,7 +4785,7 @@ xset (title.handle_value (), "verticalalignment", "bottom"); xset (title.handle_value (), "verticalalignmentmode", "auto"); xset (title.handle_value (), "clipping", "off"); - xset (title.handle_value (), "autopos_tag", "title"); + xset (title.handle_value (), "__autopos_tag__", "title"); update_title_position (); } @@ -5013,10 +5013,10 @@ xset (zlabel.handle_value (), "clipping", "off"); xset (title.handle_value (), "clipping", "off"); - xset (xlabel.handle_value (), "autopos_tag", "xlabel"); - xset (ylabel.handle_value (), "autopos_tag", "ylabel"); - xset (zlabel.handle_value (), "autopos_tag", "zlabel"); - xset (title.handle_value (), "autopos_tag", "title"); + xset (xlabel.handle_value (), "__autopos_tag__", "xlabel"); + xset (ylabel.handle_value (), "__autopos_tag__", "ylabel"); + xset (zlabel.handle_value (), "__autopos_tag__", "zlabel"); + xset (title.handle_value (), "__autopos_tag__", "title"); update_transform (); sync_positions (); @@ -6264,7 +6264,7 @@ txt_renderer.set_font (get ("fontname").string_value (), get ("fontweight").string_value (), get ("fontangle").string_value (), - get ("fontsize_points").double_value ()); + get ("__fontsize_points__").double_value ()); } // The INTERNAL flag defines whether position or outerposition is used. @@ -6588,7 +6588,7 @@ } double -axes::properties::get_fontsize_points (double box_pix_height) const +axes::properties::get___fontsize_points__ (double box_pix_height) const { double fontsz = get_fontsize (); double parent_height = box_pix_height; @@ -8041,7 +8041,7 @@ txt_renderer.set_font (get ("fontname").string_value (), get ("fontweight").string_value (), get ("fontangle").string_value (), - get ("fontsize_points").double_value ()); + get ("__fontsize_points__").double_value ()); txt_renderer.set_color (get_color_rgb ()); } @@ -8083,17 +8083,17 @@ // performed in get_extent. set_extent (bbox); - if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") - || autopos_tag_is ("zlabel") || autopos_tag_is ("title")) + if (__autopos_tag___is ("xlabel") || __autopos_tag___is ("ylabel") + || __autopos_tag___is ("zlabel") || __autopos_tag___is ("title")) update_autopos ("sync"); } void text::properties::request_autopos (void) { - if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") - || autopos_tag_is ("zlabel") || autopos_tag_is ("title")) - update_autopos (get_autopos_tag ()); + if (__autopos_tag___is ("xlabel") || __autopos_tag___is ("ylabel") + || __autopos_tag___is ("zlabel") || __autopos_tag___is ("title")) + update_autopos (get___autopos_tag__ ()); } void @@ -8132,7 +8132,7 @@ } double -text::properties::get_fontsize_points (double box_pix_height) const +text::properties::get___fontsize_points__ (double box_pix_height) const { double fontsz = get_fontsize (); double parent_height = box_pix_height; @@ -8872,7 +8872,7 @@ } double -uicontrol::properties::get_fontsize_points (double box_pix_height) const +uicontrol::properties::get___fontsize_points__ (double box_pix_height) const { double fontsz = get_fontsize (); double parent_height = box_pix_height; @@ -9004,7 +9004,7 @@ } double -uibuttongroup::properties::get_fontsize_points (double box_pix_height) const +uibuttongroup::properties::get___fontsize_points__ (double box_pix_height) const { double fontsz = get_fontsize (); double parent_height = box_pix_height; @@ -9175,7 +9175,7 @@ } double -uipanel::properties::get_fontsize_points (double box_pix_height) const +uipanel::properties::get___fontsize_points__ (double box_pix_height) const { double fontsz = get_fontsize (); double parent_height = box_pix_height;
--- a/libinterp/corefcn/graphics.in.h Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/graphics.in.h Thu Oct 27 22:13:53 2016 -0400 @@ -2615,7 +2615,7 @@ any_property userdata , Matrix () bool_property visible , "on" // additional (Octave-specific) properties - bool_property __modified__ s , "on" + bool_property __modified__ hs , "on" graphics_handle __myhandle__ fhrs , mh END_PROPERTIES @@ -3661,7 +3661,7 @@ Matrix get_extent (bool with_text = false, bool only_text_height=false) const; - double get_fontsize_points (double box_pix_height = 0) const; + double get___fontsize_points__ (double box_pix_height = 0) const; void update_boundingbox (void) { @@ -3927,7 +3927,7 @@ // Octave-specific properties double_property mousewheelzoom , 0.5 // hidden properties for alignment of subplots - radio_property autopos_tag h , "{none}|subplot" + radio_property __autopos_tag__ h , "{none}|subplot" // hidden properties for inset array_property looseinset hu , Matrix (1, 4, 0.0) // hidden properties for transformation computation @@ -3937,11 +3937,11 @@ array_property x_normrendertransform h , Matrix (4, 4, 0.0) array_property x_rendertransform h , Matrix (4, 4, 0.0) // hidden properties for minor ticks - row_vector_property xmtick h , Matrix () - row_vector_property ymtick h , Matrix () - row_vector_property zmtick h , Matrix () + row_vector_property xminortickvalues h , Matrix () + row_vector_property yminortickvalues h , Matrix () + row_vector_property zminortickvalues h , Matrix () // hidden property for text rendering - double_property fontsize_points hgr , 0 + double_property __fontsize_points__ hgr , 0 END_PROPERTIES protected: @@ -4036,8 +4036,8 @@ { if (xtickmode.is ("auto")) { - calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), - xscale.is ("log")); + calc_ticks_and_lims (xlim, xtick, xminortickvalues, + xlimmode.is ("auto"), xscale.is ("log")); update_xtick (); } } @@ -4045,8 +4045,8 @@ { if (ytickmode.is ("auto")) { - calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), - yscale.is ("log")); + calc_ticks_and_lims (ylim, ytick, yminortickvalues, + ylimmode.is ("auto"), yscale.is ("log")); update_ytick (); } } @@ -4054,8 +4054,8 @@ { if (ztickmode.is ("auto")) { - calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), - zscale.is ("log")); + calc_ticks_and_lims (zlim, ztick, zminortickvalues, + zlimmode.is ("auto"), zscale.is ("log")); update_ztick (); } } @@ -4218,8 +4218,8 @@ void update_xlim () { if (xtickmode.is ("auto")) - calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), - xscale.is ("log")); + calc_ticks_and_lims (xlim, xtick, xminortickvalues, + xlimmode.is ("auto"), xscale.is ("log")); if (xticklabelmode.is ("auto")) calc_ticklabels (xtick, xticklabel, xscale.is ("log")); @@ -4233,8 +4233,8 @@ void update_ylim (void) { if (ytickmode.is ("auto")) - calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), - yscale.is ("log")); + calc_ticks_and_lims (ylim, ytick, yminortickvalues, + ylimmode.is ("auto"), yscale.is ("log")); if (yticklabelmode.is ("auto")) calc_ticklabels (ytick, yticklabel, yscale.is ("log")); @@ -4248,8 +4248,8 @@ void update_zlim (void) { if (ztickmode.is ("auto")) - calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), - zscale.is ("log")); + calc_ticks_and_lims (zlim, ztick, zminortickvalues, + zlimmode.is ("auto"), zscale.is ("log")); if (zticklabelmode.is ("auto")) calc_ticklabels (ztick, zticklabel, zscale.is ("log")); @@ -4447,7 +4447,7 @@ class OCTINTERP_API properties : public base_properties { public: - double get_fontsize_points (double box_pix_height = 0) const; + double get___fontsize_points__ (double box_pix_height = 0) const; void set_position (const octave_value& val) { @@ -4510,9 +4510,9 @@ radio_property rotationmode hu , "{auto}|manual" radio_property horizontalalignmentmode hu , "{auto}|manual" radio_property verticalalignmentmode hu , "{auto}|manual" - radio_property autopos_tag h , "{none}|xlabel|ylabel|zlabel|title" + radio_property __autopos_tag__ h , "{none}|xlabel|ylabel|zlabel|title" // hidden property for text rendering - double_property fontsize_points hgr , 0 + double_property __fontsize_points__ hgr , 0 END_PROPERTIES Matrix get_data_position (void) const; @@ -5375,7 +5375,7 @@ double_property position , 0 bool_property separator , "off" // Octave-specific properties - string_property fltk_label h , "" + string_property __fltk_label__ h , "" END_PROPERTIES protected: @@ -5486,7 +5486,7 @@ Matrix get_boundingbox (bool internal = false, const Matrix& parent_pix_size = Matrix ()) const; - double get_fontsize_points (double box_pix_height = 0) const; + double get___fontsize_points__ (double box_pix_height = 0) const; // See the genprops.awk script for an explanation of the // properties declarations. @@ -5584,7 +5584,7 @@ Matrix get_boundingbox (bool internal = false, const Matrix& parent_pix_size = Matrix ()) const; - double get_fontsize_points (double box_pix_height = 0) const; + double get___fontsize_points__ (double box_pix_height = 0) const; // See the genprops.awk script for an explanation of the // properties declarations. @@ -5669,7 +5669,7 @@ Matrix get_boundingbox (bool internal = false, const Matrix& parent_pix_size = Matrix ()) const; - double get_fontsize_points (double box_pix_height = 0) const; + double get___fontsize_points__ (double box_pix_height = 0) const; // See the genprops.awk script for an explanation of the // properties declarations.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/corefcn/gsvd.cc Thu Oct 27 22:13:53 2016 -0400 @@ -0,0 +1,488 @@ +// Copyright (C) 2016 Barbara Lócsi +// Copyright (C) 2006, 2010 Pascal Dupuis <Pascal.Dupuis@uclouvain.be> +// Copyright (C) 1996, 1997 John W. Eaton +// +// This program 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. +// +// This program 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 +// this program; if not, see <http://www.gnu.org/licenses/>. + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "dMatrix.h" +#include "CMatrix.h" +#include "dDiagMatrix.h" +#include "gsvd.h" + +#include "defun.h" +#include "defun-int.h" +#include "error.h" +#include "errwarn.h" +#include "utils.h" +#include "ovl.h" +#include "ov.h" + + +template <typename T> +static typename octave::math::gsvd<T>::Type +gsvd_type (int nargout) +{ + return ((nargout == 0 || nargout == 1) + ? octave::math::gsvd<T>::Type::sigma_only + : (nargout > 5) ? octave::math::gsvd<T>::Type::std + : octave::math::gsvd<T>::Type::economy); +} + +// Named like this to avoid conflicts with the gsvd class. +template <typename T> +static octave_value_list +do_gsvd (const T& A, const T& B, const octave_idx_type nargout, + bool is_single = false) +{ + octave::math::gsvd<T> result (A, B, gsvd_type<T> (nargout)); + + octave_value_list retval (nargout); + if (nargout < 2) + { + if (is_single) + { + FloatDiagMatrix sigA = result.singular_values_A (); + FloatDiagMatrix sigB = result.singular_values_B (); + for (int i = sigA.rows () - 1; i >= 0; i--) + sigA.dgxelem(i) /= sigB.dgxelem(i); + retval(0) = sigA.diag (); + } + else + { + DiagMatrix sigA = result.singular_values_A (); + DiagMatrix sigB = result.singular_values_B (); + for (int i = sigA.rows () - 1; i >= 0; i--) + sigA.dgxelem(i) /= sigB.dgxelem(i); + retval(0) = sigA.diag (); + } + } + else + { + retval(0) = result.left_singular_matrix_A (); + retval(1) = result.left_singular_matrix_B (); + if (nargout > 2) + retval(2) = result.right_singular_matrix (); + if (nargout > 3) + retval(3) = result.singular_values_A (); + if (nargout > 4) + retval(4) = result.singular_values_B (); + if (nargout > 5) + retval(5) = result.R_matrix (); + } + return retval; +} + +DEFUN (gsvd, args, nargout, + doc: /* -*- texinfo -*- +@deftypefn {} {@var{S} =} gsvd (@var{A}, @var{B}) +@deftypefnx {} {[@var{U}, @var{V}, @var{X}, @var{C}, @var{S}] =} gsvd (@var{A}, @var{B}) +@deftypefnx {} {[@var{U}, @var{V}, @var{X}, @var{C}, @var{S}] =} gsvd (@var{A}, @var{B}, 0) +Compute the generalized singular value decomposition of (@var{A}, @var{B}): + +@tex +$$ A = U C X^\dagger $$ +$$ B = V S X^\dagger $$ +$$ C^\dagger C + S^\dagger S = eye (columns (A)) $$ +@end tex +@ifnottex + +@example +@group +A = U*C*X' +B = V*S*X' +C'*C + S'*S = eye (columns (A)) +@end group +@end example + +@end ifnottex + +The function @code{gsvd} normally returns just the vector of generalized singular values +@tex +$$ \sqrt{{{diag (C^\dagger C)} \over {diag (S^\dagger S)}}} $$ +@end tex +@ifnottex +@code{sqrt (diag (C'*C) ./ diag (S'*S))}. +@end ifnottex +If asked for five return values, it also computes +@tex +$U$, $V$, $X$, and $C$. +@end tex +@ifnottex +U, V, X, and C. +@end ifnottex + +If the optional third input is present, @code{gsvd} constructs the +"economy-sized" decomposition where the number of columns of @var{U}, @var{V} +and the number of rows of @var{C}, @var{S} is less than or equal to the number +of columns of @var{A}. This option is not yet implemented. + +Programming Note: the code is a wrapper to the corresponding @sc{lapack} dggsvd +and zggsvd routines. + +@seealso{svd} +@end deftypefn */) +{ + int nargin = args.length (); + + if (nargin < 2 || nargin > 3) + print_usage (); + else if (nargin == 3) + warning ("gsvd: economy-sized decomposition is not yet implemented, returning full decomposition"); + + octave_value_list retval; + + octave_value argA = args(0); + octave_value argB = args(1); + + octave_idx_type nr = argA.rows (); + octave_idx_type nc = argA.columns (); + + octave_idx_type np = argB.columns (); + + // FIXME: This "special" case should be handled in the gsvd class, not here + if (nr == 0 || nc == 0) + { + retval = octave_value_list (nargout); + if (nargout < 2) // S = gsvd (A, B) + { + if (argA.is_single_type () || argB.is_single_type ()) + retval(0) = FloatMatrix (0, 1); + else + retval(0) = Matrix (0, 1); + } + else // [U, V, X, C, S, R] = gsvd (A, B) + { + if (argA.is_single_type () || argB.is_single_type ()) + { + retval(0) = float_identity_matrix (nc, nc); + retval(1) = float_identity_matrix (nc, nc); + if (nargout > 2) + retval(2) = float_identity_matrix (nr, nr); + if (nargout > 3) + retval(3) = FloatMatrix (nr, nc); + if (nargout > 4) + retval(4) = float_identity_matrix (nr, nr); + if (nargout > 5) + retval(5) = float_identity_matrix (nr, nr); + } + else + { + retval(0) = identity_matrix (nc, nc); + retval(1) = identity_matrix (nc, nc); + if (nargout > 2) + retval(2) = identity_matrix (nr, nr); + if (nargout > 3) + retval(3) = Matrix (nr, nc); + if (nargout > 4) + retval(4) = identity_matrix (nr, nr); + if (nargout > 5) + retval(5) = identity_matrix (nr, nr); + } + } + } + else + { + if (nc != np) + print_usage (); + + if (argA.is_single_type () || argB.is_single_type ()) + { + if (argA.is_real_type () && argB.is_real_type ()) + { + FloatMatrix tmpA = argA.xfloat_matrix_value ("gsvd: A must be a real or complex matrix"); + FloatMatrix tmpB = argB.xfloat_matrix_value ("gsvd: B must be a real or complex matrix"); + + if (tmpA.any_element_is_inf_or_nan ()) + error ("gsvd: A cannot have Inf or NaN values"); + if (tmpB.any_element_is_inf_or_nan ()) + error ("gsvd: B cannot have Inf or NaN values"); + + retval = do_gsvd (tmpA, tmpB, nargout, true); + } + else if (argA.is_complex_type () || argB.is_complex_type ()) + { + FloatComplexMatrix ctmpA = argA.xfloat_complex_matrix_value ("gsvd: A must be a real or complex matrix"); + FloatComplexMatrix ctmpB = argB.xfloat_complex_matrix_value ("gsvd: B must be a real or complex matrix"); + + if (ctmpA.any_element_is_inf_or_nan ()) + error ("gsvd: A cannot have Inf or NaN values"); + if (ctmpB.any_element_is_inf_or_nan ()) + error ("gsvd: B cannot have Inf or NaN values"); + + retval = do_gsvd (ctmpA, ctmpB, nargout, true); + } + else + error ("gsvd: A and B must be real or complex matrices"); + } + else + { + if (argA.is_real_type () && argB.is_real_type ()) + { + Matrix tmpA = argA.xmatrix_value ("gsvd: A must be a real or complex matrix"); + Matrix tmpB = argB.xmatrix_value ("gsvd: B must be a real or complex matrix"); + + if (tmpA.any_element_is_inf_or_nan ()) + error ("gsvd: A cannot have Inf or NaN values"); + if (tmpB.any_element_is_inf_or_nan ()) + error ("gsvd: B cannot have Inf or NaN values"); + + retval = do_gsvd (tmpA, tmpB, nargout); + } + else if (argA.is_complex_type () || argB.is_complex_type ()) + { + ComplexMatrix ctmpA = argA.xcomplex_matrix_value ("gsvd: A must be a real or complex matrix"); + ComplexMatrix ctmpB = argB.xcomplex_matrix_value ("gsvd: B must be a real or complex matrix"); + + if (ctmpA.any_element_is_inf_or_nan ()) + error ("gsvd: A cannot have Inf or NaN values"); + if (ctmpB.any_element_is_inf_or_nan ()) + error ("gsvd: B cannot have Inf or NaN values"); + + retval = do_gsvd (ctmpA, ctmpB, nargout); + } + else + error ("gsvd: A and B must be real or complex matrices"); + } + } + + return retval; +} + +/* + +## Basic test of decomposition +%!test <48807> +%! A = reshape (1:15,5,3); +%! B = magic (3); +%! [U,V,X,C,S] = gsvd (A,B); +%! assert (U*C*X', A, 50*eps); +%! assert (V*S*X', B, 50*eps); +%! S0 = gsvd (A, B); +%! S1 = svd (A / B); +%! assert (S0, S1, 10*eps); + +## a few tests for gsvd.m +%!shared A, A0, B, B0, U, V, C, S, X, R, D1, D2 +%! A0 = randn (5, 3); +%! B0 = diag ([1 2 4]); +%! A = A0; +%! B = B0; + +## A (5x3) and B (3x3) are full rank +%!test <48807> +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros (5, 3); D1(1:3, 1:3) = C; +%! D2 = S; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 5x3 full rank, B: 3x3 rank deficient +%!test <48807> +%! B(2, 2) = 0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros (5, 3); D1(1, 1) = 1; D1(2:3, 2:3) = C; +%! D2 = [zeros(2, 1) S; zeros(1, 3)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 5x3 rank deficient, B: 3x3 full rank +%!test <48807> +%! B = B0; +%! A(:, 3) = 2*A(:, 1) - A(:, 2); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 3); D1(1:3, 1:3) = C; +%! D2 = S; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A and B are both rank deficient +%!test <48807> +%! B(:, 3) = 2*B(:, 1) - B(:, 2); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 2); D1(1:2, 1:2) = C; +%! D2 = [S; zeros(1, 2)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*[zeros(2, 1) R]) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*[zeros(2, 1) R]) <= 1e-6); + +## A (now 3x5) and B (now 5x5) are full rank +%!test <48807> +%! A = A0.'; +%! B0 = diag ([1 2 4 8 16]); +%! B = B0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = [C zeros(3,2)]; +%! D2 = [S zeros(3,2); zeros(2, 3) eye(2)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 3x5 full rank, B: 5x5 rank deficient +%!test <48807> +%! B(2, 2) = 0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(3, 5); D1(1, 1) = 1; D1(2:3, 2:3) = C; +%! D2 = zeros(5, 5); D2(1:2, 2:3) = S; D2(3:4, 4:5) = eye (2); +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 3x5 rank deficient, B: 5x5 full rank +%!test <48807> +%! B = B0; +%! A(3, :) = 2*A(1, :) - A(2, :); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros (3, 5); D1(1:3, 1:3) = C; +%! D2 = zeros (5, 5); D2(1:3, 1:3) = S; D2(4:5, 4:5) = eye (2); +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A and B are both rank deficient +%!test <48807> +%! A = A0.'; B = B0.'; +%! A(:, 3) = 2*A(:, 1) - A(:, 2); +%! B(:, 3) = 2*B(:, 1) - B(:, 2); +%! [U, V, X, C, S, R]=gsvd (A, B); +%! D1 = zeros(3, 4); D1(1:3, 1:3) = C; +%! D2 = eye (4); D2(1:3, 1:3) = S; D2(5,:) = 0; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*[zeros(4, 1) R]) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*[zeros(4, 1) R]) <= 1e-6); + +## A: 5x3 complex full rank, B: 3x3 complex full rank +%!test <48807> +%! A0 = A0 + j*randn (5, 3); +%! B0 = diag ([1 2 4]) + j*diag ([4 -2 -1]); +%! A = A0; +%! B = B0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 3); D1(1:3, 1:3) = C; +%! D2 = S; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 5x3 complex full rank, B: 3x3 complex rank deficient +%!test <48807> +%! B(2, 2) = 0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 3); D1(1, 1) = 1; D1(2:3, 2:3) = C; +%! D2 = [zeros(2, 1) S; zeros(1, 3)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 5x3 complex rank deficient, B: 3x3 complex full rank +%!test <48807> +%! B = B0; +%! A(:, 3) = 2*A(:, 1) - A(:, 2); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 3); D1(1:3, 1:3) = C; +%! D2 = S; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A (5x3) and B (3x3) are both complex rank deficient +%!test <48807> +%! B(:, 3) = 2*B(:, 1) - B(:, 2); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(5, 2); D1(1:2, 1:2) = C; +%! D2 = [S; zeros(1, 2)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*[zeros(2, 1) R]) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*[zeros(2, 1) R]) <= 1e-6); + +## A (now 3x5) complex and B (now 5x5) complex are full rank +## now, A is 3x5 +%!test <48807> +%! A = A0.'; +%! B0 = diag ([1 2 4 8 16]) + j*diag ([-5 4 -3 2 -1]); +%! B = B0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = [C zeros(3,2)]; +%! D2 = [S zeros(3,2); zeros(2, 3) eye(2)]; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 3x5 complex full rank, B: 5x5 complex rank deficient +%!test <48807> +%! B(2, 2) = 0; +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(3, 5); D1(1, 1) = 1; D1(2:3, 2:3) = C; +%! D2 = zeros(5,5); D2(1:2, 2:3) = S; D2(3:4, 4:5) = eye (2); +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (2, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A: 3x5 complex rank deficient, B: 5x5 complex full rank +%!test <48807> +%! B = B0; +%! A(3, :) = 2*A(1, :) - A(2, :); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(3, 5); D1(1:3, 1:3) = C; +%! D2 = zeros(5,5); D2(1:3, 1:3) = S; D2(4:5, 4:5) = eye (2); +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*R) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*R) <= 1e-6); + +## A and B are both complex rank deficient +%!test <48807> +%! A = A0.'; +%! B = B0.'; +%! A(:, 3) = 2*A(:, 1) - A(:, 2); +%! B(:, 3) = 2*B(:, 1) - B(:, 2); +%! [U, V, X, C, S, R] = gsvd (A, B); +%! D1 = zeros(3, 4); D1(1:3, 1:3) = C; +%! D2 = eye (4); D2(1:3, 1:3) = S; D2(5,:) = 0; +%! assert (norm (diag (C).^2 + diag (S).^2 - ones (3, 1)) <= 1e-6); +%! assert (norm ((U'*A*X) - D1*[zeros(4, 1) R]) <= 1e-6); +%! assert (norm ((V'*B*X) - D2*[zeros(4, 1) R]) <= 1e-6); + +## Test that single inputs produce single outputs +%!test +%! s = gsvd (single (ones (0,1)), B); +%! assert (class (s), "single"); +%! s = gsvd (single (ones (1,0)), B); +%! assert (class (s), "single"); +%! s = gsvd (single (ones (1,0)), B); +%! [U,V,X,C,S,R] = gsvd (single ([]), B); +%! assert (class (U), "single"); +%! assert (class (V), "single"); +%! assert (class (X), "single"); +%! assert (class (C), "single"); +%! assert (class (S), "single"); +%! assert (class (R), "single"); +%! +%! s = gsvd (single (A), B); +%! assert (class (s), "single"); +%! [U,V,X,C,S,R] = gsvd (single (A), B); +%! assert (class (U), "single"); +%! assert (class (V), "single"); +%! assert (class (X), "single"); +%! assert (class (C), "single"); +%! assert (class (S), "single"); +%! assert (class (R), "single"); + +*/ +
--- a/libinterp/corefcn/module.mk Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/module.mk Thu Oct 27 22:13:53 2016 -0400 @@ -116,7 +116,6 @@ COREFCN_SRC = \ libinterp/corefcn/Cell.cc \ libinterp/corefcn/__contourc__.cc \ - libinterp/corefcn/__dispatch__.cc \ libinterp/corefcn/__dsearchn__.cc \ libinterp/corefcn/__ichol__.cc \ libinterp/corefcn/__ilu__.cc \ @@ -173,6 +172,7 @@ libinterp/corefcn/gl2ps-print.cc \ libinterp/corefcn/graphics.cc \ libinterp/corefcn/gripes.cc \ + libinterp/corefcn/gsvd.cc \ libinterp/corefcn/hash.cc \ libinterp/corefcn/help.cc \ libinterp/corefcn/hess.cc \
--- a/libinterp/corefcn/svd.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/svd.cc Thu Oct 27 22:13:53 2016 -0400 @@ -38,13 +38,22 @@ template <typename T> static typename octave::math::svd<T>::Type -svd_type (int nargin, int nargout) +svd_type (int nargin, int nargout, const octave_value_list & args, const T & A) { - return ((nargout == 0 || nargout == 1) - ? octave::math::svd<T>::Type::sigma_only - : ((nargin == 2) - ? octave::math::svd<T>::Type::economy - : octave::math::svd<T>::Type::std)); + if (nargout == 0 || nargout == 1) + return octave::math::svd<T>::Type::sigma_only; + else if (nargin == 1) + return octave::math::svd<T>::Type::std; + else + if (! args(1).is_real_scalar ()) + return octave::math::svd<T>::Type::economy; + else + { + if (A.rows () > A.columns ()) + return octave::math::svd<T>::Type::economy; + else + return octave::math::svd<T>::Type::std; + } } template <typename T> @@ -60,7 +69,8 @@ doc: /* -*- texinfo -*- @deftypefn {} {@var{s} =} svd (@var{A}) @deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}) -@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, @var{econ}) +@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, "econ") +@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, 0) @cindex singular value decomposition Compute the singular value decomposition of @var{A} @tex @@ -135,9 +145,14 @@ @end group @end example -If given a second argument, @code{svd} returns an economy-sized +When given a second argument that is not 0, @code{svd} returns an economy-sized decomposition, eliminating the unnecessary rows or columns of @var{U} or @var{V}. + +If the second argument is exactly 0, then the choice of decomposition is based +on the matrix @var{A}. If @var{A} has more rows than columns then an +economy-sized decomposition is returned, otherwise a regular decomposition +is calculated. @seealso{svd_driver, svds, eig, lu, chol, hess, qr, qz} @end deftypefn */) { @@ -165,7 +180,8 @@ error ("svd: cannot take SVD of matrix containing Inf or NaN values"); octave::math::svd<FloatMatrix> result - (tmp, svd_type<FloatMatrix> (nargin, nargout), + (tmp, + svd_type<FloatMatrix> (nargin, nargout, args, tmp), svd_driver<FloatMatrix> ()); FloatDiagMatrix sigma = result.singular_values (); @@ -185,7 +201,8 @@ error ("svd: cannot take SVD of matrix containing Inf or NaN values"); octave::math::svd<FloatComplexMatrix> result - (ctmp, svd_type<FloatComplexMatrix> (nargin, nargout), + (ctmp, + svd_type<FloatComplexMatrix> (nargin, nargout, args, ctmp), svd_driver<FloatComplexMatrix> ()); FloatDiagMatrix sigma = result.singular_values (); @@ -208,7 +225,8 @@ error ("svd: cannot take SVD of matrix containing Inf or NaN values"); octave::math::svd<Matrix> result - (tmp, svd_type<Matrix> (nargin, nargout), + (tmp, + svd_type<Matrix> (nargin, nargout, args, tmp), svd_driver<Matrix> ()); DiagMatrix sigma = result.singular_values (); @@ -228,7 +246,8 @@ error ("svd: cannot take SVD of matrix containing Inf or NaN values"); octave::math::svd<ComplexMatrix> result - (ctmp, svd_type<ComplexMatrix> (nargin, nargout), + (ctmp, + svd_type<ComplexMatrix> (nargin, nargout, args, ctmp), svd_driver<ComplexMatrix> ()); DiagMatrix sigma = result.singular_values (); @@ -255,7 +274,6 @@ [u,s,v] = svd (a); assert (a, u * s * v', 128 * eps); - %!test %! [u, s, v] = svd ([1, 2; 2, 1]); %! x = 1 / sqrt (2); @@ -326,6 +344,12 @@ %! assert (size (s), [0, 0]); %! assert (size (v), [0, 0]); +%!test <49309> +%! [~,~,v] = svd ([1, 1, 1], 0); +%! assert (size (v), [3 3]); +%! [~,~,v] = svd ([1, 1, 1], "econ"); +%! assert (size (v), [3 1]); + %!error svd () %!error svd ([1, 2; 4, 5], 2, 3) %!error [u, v] = svd ([1, 2; 3, 4])
--- a/libinterp/corefcn/symtab.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/symtab.cc Thu Oct 27 22:13:53 2016 -0400 @@ -550,41 +550,6 @@ } } -void -symbol_table::fcn_info::fcn_info_rep::print_dispatch (std::ostream& os) const -{ - if (dispatch_map.empty ()) - os << "dispatch: " << name << " is not overloaded" << std::endl; - else - { - os << "Overloaded function " << name << ":\n\n"; - - for (dispatch_map_const_iterator p = dispatch_map.begin (); - p != dispatch_map.end (); p++) - os << " " << name << " (" << p->first << ", ...) -> " - << p->second << " (" << p->first << ", ...)\n"; - - os << std::endl; - } -} - -std::string -symbol_table::fcn_info::fcn_info_rep::help_for_dispatch (void) const -{ - std::string retval; - - if (! dispatch_map.empty ()) - { - retval = "Overloaded function:\n\n"; - - for (dispatch_map_const_iterator p = dispatch_map.begin (); - p != dispatch_map.end (); p++) - retval += " " + p->second + " (" + p->first + ", ...)\n\n"; - } - - return retval; -} - // :-) JWE, can you parse this? Returns a 2D array with second dimension equal // to btyp_num_types (static constant). Only the leftmost dimension can be // variable in C/C++. Typedefs are boring. @@ -687,7 +652,6 @@ // private function // class method // class constructor -// legacy dispatch // command-line function // autoload function // function on the path @@ -824,31 +788,6 @@ } } - // Legacy dispatch. - - if (! args.empty () && ! dispatch_map.empty ()) - { - std::string dispatch_type = args(0).type_name (); - - std::string fname; - - dispatch_map_iterator p = dispatch_map.find (dispatch_type); - - if (p == dispatch_map.end ()) - p = dispatch_map.find ("any"); - - if (p != dispatch_map.end ()) - { - fname = p->second; - - octave_value fcn - = symbol_table::find_function (fname, args); - - if (fcn.is_defined ()) - return fcn; - } - } - // Command-line function. if (cmdline_function.is_defined ()) @@ -896,8 +835,7 @@ // But since the list of built-in functions is different in Octave and // Matlab, we also search up the precedence list until we find // something that matches. Note that we are only searching by name, -// so class methods, constructors, and legacy dispatch functions are -// skipped. +// so class methods and constructors are skipped. octave_value symbol_table::fcn_info::fcn_info_rep::builtin_find (void) @@ -1224,14 +1162,6 @@ os << tprefix << "method: " << fcn_file_name (p->second) << " [" << p->first << "]\n"; } - - if (! dispatch_map.empty ()) - { - for (dispatch_map_const_iterator p = dispatch_map.begin (); - p != dispatch_map.end (); p++) - os << tprefix << "dispatch: " << fcn_file_name (p->second) - << " [" << p->first << "]\n"; - } } void
--- a/libinterp/corefcn/symtab.h Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/corefcn/symtab.h Thu Oct 27 22:13:53 2016 -0400 @@ -733,8 +733,6 @@ { public: - typedef std::map<std::string, std::string> dispatch_map_type; - typedef std::map<scope_id, octave_value>::const_iterator scope_val_const_iterator; typedef std::map<scope_id, octave_value>::iterator scope_val_iterator; @@ -743,9 +741,6 @@ str_val_const_iterator; typedef std::map<std::string, octave_value>::iterator str_val_iterator; - typedef dispatch_map_type::const_iterator dispatch_map_const_iterator; - typedef dispatch_map_type::iterator dispatch_map_iterator; - private: class @@ -755,9 +750,9 @@ fcn_info_rep (const std::string& nm) : name (nm), package_name (), subfunctions (), private_functions (), - class_constructors (), class_methods (), dispatch_map (), - cmdline_function (), autoload_function (), function_on_path (), - built_in_function (), count (1) + class_constructors (), class_methods (), cmdline_function (), + autoload_function (), function_on_path (), built_in_function (), + count (1) { size_t pos = name.rfind ('.'); @@ -911,25 +906,6 @@ clear_package (); } - void add_dispatch (const std::string& type, const std::string& fname) - { - dispatch_map[type] = fname; - } - - void clear_dispatch (const std::string& type) - { - dispatch_map_iterator p = dispatch_map.find (type); - - if (p != dispatch_map.end ()) - dispatch_map.erase (p); - } - - void print_dispatch (std::ostream& os) const; - - std::string help_for_dispatch (void) const; - - dispatch_map_type get_dispatch (void) const { return dispatch_map; } - void dump (std::ostream& os, const std::string& prefix) const; std::string full_name (void) const @@ -956,9 +932,6 @@ // Dispatch type to function object. std::map<std::string, octave_value> class_methods; - // Legacy dispatch map (dispatch type name to function name). - dispatch_map_type dispatch_map; - octave_value cmdline_function; octave_value autoload_function; @@ -1123,29 +1096,6 @@ void clear_mex_function (void) { rep->clear_mex_function (); } - void add_dispatch (const std::string& type, const std::string& fname) - { - rep->add_dispatch (type, fname); - } - - void clear_dispatch (const std::string& type) - { - rep->clear_dispatch (type); - } - - void print_dispatch (std::ostream& os) const - { - rep->print_dispatch (os); - } - - std::string help_for_dispatch (void) const - { return rep->help_for_dispatch (); } - - dispatch_map_type get_dispatch (void) const - { - return rep->get_dispatch (); - } - void dump (std::ostream& os, const std::string& prefix = "") const { @@ -1845,83 +1795,6 @@ panic ("alias: '%s' is undefined", name.c_str ()); } - static void add_dispatch (const std::string& name, const std::string& type, - const std::string& fname) - { - fcn_table_iterator p = fcn_table.find (name); - - if (p != fcn_table.end ()) - { - fcn_info& finfo = p->second; - - finfo.add_dispatch (type, fname); - } - else - { - fcn_info finfo (name); - - finfo.add_dispatch (type, fname); - - fcn_table[name] = finfo; - } - } - - static void clear_dispatch (const std::string& name, const std::string& type) - { - fcn_table_iterator p = fcn_table.find (name); - - if (p != fcn_table.end ()) - { - fcn_info& finfo = p->second; - - finfo.clear_dispatch (type); - } - } - - static void print_dispatch (std::ostream& os, const std::string& name) - { - fcn_table_iterator p = fcn_table.find (name); - - if (p != fcn_table.end ()) - { - fcn_info& finfo = p->second; - - finfo.print_dispatch (os); - } - } - - static fcn_info::dispatch_map_type get_dispatch (const std::string& name) - { - fcn_info::dispatch_map_type retval; - - fcn_table_iterator p = fcn_table.find (name); - - if (p != fcn_table.end ()) - { - fcn_info& finfo = p->second; - - retval = finfo.get_dispatch (); - } - - return retval; - } - - static std::string help_for_dispatch (const std::string& name) - { - std::string retval; - - fcn_table_iterator p = fcn_table.find (name); - - if (p != fcn_table.end ()) - { - fcn_info& finfo = p->second; - - retval = finfo.help_for_dispatch (); - } - - return retval; - } - static void push_context (scope_id scope = xcurrent_scope) { if (scope == xglobal_scope || scope == xtop_scope) @@ -2953,6 +2826,7 @@ extern OCTINTERP_API std::string get_dispatch_type (const octave_value_list& args); + extern OCTINTERP_API std::string get_dispatch_type (const octave_value_list& args, builtin_type_t& builtin_type);
--- a/libinterp/dldfcn/__init_fltk__.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/dldfcn/__init_fltk__.cc Thu Oct 27 22:13:53 2016 -0400 @@ -423,7 +423,7 @@ void delete_entry (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); int idx = find_index_by_name (fltk_label.c_str ()); if (idx >= 0) @@ -432,7 +432,7 @@ void update_accelerator (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( @@ -451,7 +451,7 @@ void update_callback (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( @@ -469,7 +469,7 @@ void update_enable (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( @@ -486,7 +486,7 @@ void update_foregroundcolor (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( @@ -509,7 +509,7 @@ // Matlab places the separator before the current // menu entry, while fltk places it after. So we need to find // the previous item in this menu/submenu. (Kai) - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { int itemflags = 0, idx; @@ -539,7 +539,7 @@ void update_visible (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { Fl_Menu_Item* item @@ -563,7 +563,7 @@ void add_entry (uimenu::properties& uimenup) { - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { @@ -606,7 +606,7 @@ } } while (! item_added); - uimenup.set_fltk_label (fltk_label); + uimenup.set___fltk_label__ (fltk_label); } } @@ -615,7 +615,7 @@ std::vector<int> delayed_menus; Matrix kids = find_uimenu_children (uimenup); int len = kids.numel (); - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); int count = 0; add_entry (uimenup); @@ -897,7 +897,7 @@ { uimenu::properties& uimenup = dynamic_cast<uimenu::properties&> (uimenu_obj.get_properties ()); - std::string fltk_label = uimenup.get_fltk_label (); + std::string fltk_label = uimenup.get___fltk_label__ (); graphics_object fig = uimenu_obj.get_ancestor ("figure"); figure::properties& figp = dynamic_cast<figure::properties&> (fig.get_properties ()); @@ -2218,7 +2218,7 @@ } } - void uimenu_set_fltk_label (graphics_object uimenu_obj) + void uimenu_set___fltk_label__ (graphics_object uimenu_obj) { if (uimenu_obj.valid_object ()) { @@ -2228,7 +2228,7 @@ graphics_object go = gh_manager::get_object (uimenu_obj.get_parent ()); if (go.isa ("uimenu")) fltk_label = dynamic_cast<const uimenu::properties&> - (go.get_properties ()).get_fltk_label () + (go.get_properties ()).get___fltk_label__ () + "/" + fltk_label; else if (go.isa ("figure") || go.isa ("uicontextmenu")) @@ -2236,7 +2236,7 @@ else error ("invalid parent object\n"); - uimenup.set_fltk_label (fltk_label); + uimenup.set___fltk_label__ (fltk_label); } } @@ -2295,7 +2295,7 @@ else if (go.isa ("uimenu")) { if (id == uimenu::properties::ID_LABEL) - uimenu_set_fltk_label (go); + uimenu_set___fltk_label__ (go); graphics_object fig = go.get_ancestor ("figure"); figure_manager::uimenu_update (fig.get_handle (), go.get_handle (), id);
--- a/libinterp/octave-value/ov-fcn-handle.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/octave-value/ov-fcn-handle.cc Thu Oct 27 22:13:53 2016 -0400 @@ -2039,28 +2039,19 @@ bad = true; else { - // Function handles can't handle legacy - // dispatch, so we make sure it's not - // defined. + // Simulate try/catch. + octave::unwind_protect frame; + interpreter_try (frame); - if (symbol_table::get_dispatch (head_name).size () > 0) - bad = true; - else + try { - // Simulate try/catch. - octave::unwind_protect frame; - interpreter_try (frame); + root_val = make_fcn_handle (head_name); + } + catch (const octave::execution_exception&) + { + recover_from_exception (); - try - { - root_val = make_fcn_handle (head_name); - } - catch (const octave::execution_exception&) - { - recover_from_exception (); - - bad = true; - } + bad = true; } } }
--- a/libinterp/octave-value/ov-range.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/octave-value/ov-range.cc Thu Oct 27 22:13:53 2016 -0400 @@ -57,8 +57,6 @@ #include "ls-hdf5.h" #include "ls-utils.h" -// If TRUE, allow ranges with non-integer elements as array indices. -static bool Vallow_noninteger_range_as_index = true; DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_range, "range", "double"); @@ -173,9 +171,7 @@ return *idx_cache; else { - if (require_integers - || ! Vallow_noninteger_range_as_index - || range.all_elements_are_ints ()) + if (require_integers || range.all_elements_are_ints ()) return set_idx_cache (idx_vector (range)); else { @@ -780,52 +776,3 @@ : octave_value (); } -DEFUN (allow_noninteger_range_as_index, args, nargout, - doc: /* -*- texinfo -*- -@deftypefn {} {@var{val} =} allow_noninteger_range_as_index () -@deftypefnx {} {@var{old_val} =} allow_noninteger_range_as_index (@var{new_val}) -@deftypefnx {} {} allow_noninteger_range_as_index (@var{new_val}, "local") -Query or set the internal variable that controls whether non-integer -ranges are allowed as indices. - -This might be useful for @sc{matlab} compatibility; however, it is still not -entirely compatible because @sc{matlab} treats the range expression -differently in different contexts. - -When called from inside a function with the @qcode{"local"} option, the -variable is changed locally for the function and any subroutines it calls. -The original variable value is restored when exiting the function. -@end deftypefn */) -{ - static bool warned = false; - if (! warned) - { - warned = true; - warning_with_id ("Octave:deprecated-function", - "allow_noninteger_range_as_index is obsolete and will be removed from a future version of Octave"); - } - - return SET_INTERNAL_VARIABLE (allow_noninteger_range_as_index); -} - -/* -%!test -%! x = 0:10; -%! warning ("off", "Octave:deprecated-function", "local"); -%! save = allow_noninteger_range_as_index (); -%! warn_state = warning ("query", "Octave:noninteger-range-as-index"); -%! unwind_protect -%! allow_noninteger_range_as_index (false); -%! fail ("x(2.1:5)"); -%! assert (x(2:5), 1:4); -%! allow_noninteger_range_as_index (true); -%! warning ("off", "Octave:noninteger-range-as-index"); -%! assert (x(2.49:5), 1:3); -%! assert (x(2.5:5), 2:4); -%! assert (x(2.51:5), 2:4); -%! unwind_protect_cleanup -%! allow_noninteger_range_as_index (save); -%! warning (warn_state.state, warn_state.identifier); -%! end_unwind_protect -*/ -
--- a/libinterp/parse-tree/pt-binop.cc Thu Oct 27 22:02:40 2016 -0400 +++ b/libinterp/parse-tree/pt-binop.cc Thu Oct 27 22:13:53 2016 -0400 @@ -34,9 +34,6 @@ #include "pt-walk.h" #include "variables.h" -// TRUE means we mark | and & expressions for braindead short-circuit -// behavior. -static bool Vdo_braindead_shortcircuit_evaluation = true; // Binary expressions. @@ -69,8 +66,7 @@ { octave_value retval; - if (Vdo_braindead_shortcircuit_evaluation - && eligible_for_braindead_shortcircuit) + if (eligible_for_braindead_shortcircuit) { if (op_lhs) { @@ -259,47 +255,3 @@ return new_be; } -DEFUN (do_braindead_shortcircuit_evaluation, args, nargout, - doc: /* -*- texinfo -*- -@deftypefn {} {@var{val} =} do_braindead_shortcircuit_evaluation () -@deftypefnx {} {@var{old_val} =} do_braindead_shortcircuit_evaluation (@var{new_val}) -@deftypefnx {} {} do_braindead_shortcircuit_evaluation (@var{new_val}, "local") -Query or set the internal variable that controls whether Octave will -do short-circuit evaluation of @samp{|} and @samp{&} operators inside the -conditions of if or while statements. - -This feature is only provided for compatibility with @sc{matlab} and should -not be used unless you are porting old code that relies on this feature. - -To obtain short-circuit behavior for logical expressions in new programs, -you should always use the @samp{&&} and @samp{||} operators. - -When called from inside a function with the @qcode{"local"} option, the -variable is changed locally for the function and any subroutines it calls. -The original variable value is restored when exiting the function. -@end deftypefn */) -{ - static bool warned = false; - if (! warned) - { - warned = true; - warning_with_id ("Octave:deprecated-function", - "do_braindead_shortcircuit_evaluation is obsolete and will be removed from a future version of Octave"); - } - - return SET_INTERNAL_VARIABLE (do_braindead_shortcircuit_evaluation); -} - -/* -%!test -%! x = 0; -%! do_braindead_shortcircuit_evaluation (0); -%! if (1 | (x = 1)) -%! endif -%! assert (x, 1); -%! do_braindead_shortcircuit_evaluation (1); -%! if (1 | (x = 0)) -%! endif -%! assert (x, 1); -*/ -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/numeric/gsvd.cc Thu Oct 27 22:13:53 2016 -0400 @@ -0,0 +1,371 @@ +// Copyright (C) 2016 Barbara Lócsi +// Copyright (C) 2006 Pascal Dupuis <Pascal.Dupuis@uclouvain.be> +// Copyright (C) 1996, 1997 John W. Eaton +// +// This program 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. +// +// This program 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 +// this program; if not, see <http://www.gnu.org/licenses/>. + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <vector> + +#include "gsvd.h" + +#include "lo-error.h" +#include "lo-lapack-proto.h" +#include "dMatrix.h" +#include "fMatrix.h" +#include "CMatrix.h" +#include "fCMatrix.h" +#include "dDiagMatrix.h" +#include "fDiagMatrix.h" + +namespace octave +{ + namespace math + { + template <> + void + gsvd<Matrix>::ggsvd (char& jobu, char& jobv, char& jobq, + octave_idx_type m, octave_idx_type n, + octave_idx_type p, + octave_idx_type& k, octave_idx_type& l, + double *tmp_dataA, octave_idx_type m1, + double *tmp_dataB, octave_idx_type p1, Matrix& alpha, + Matrix& beta, double *u, octave_idx_type nrow_u, + double *v, octave_idx_type nrow_v, double *q, + octave_idx_type nrow_q, + Matrix& work, octave_idx_type* iwork, + octave_idx_type& info) + { + F77_XFCN (dggsvd, DGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), + F77_CONST_CHAR_ARG2 (&jobv, 1), + F77_CONST_CHAR_ARG2 (&jobq, 1), + m, n, p, k, l, tmp_dataA, m1, + tmp_dataB, p1, alpha.fortran_vec (), + beta.fortran_vec (), u, nrow_u, + v, nrow_v, q, nrow_q, work.fortran_vec (), + iwork, info + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1))); + } + + template <> + void + gsvd<FloatMatrix>::ggsvd (char& jobu, char& jobv, char& jobq, + octave_idx_type m, octave_idx_type n, + octave_idx_type p, + octave_idx_type& k, octave_idx_type& l, + float *tmp_dataA, octave_idx_type m1, + float *tmp_dataB, octave_idx_type p1, + FloatMatrix& alpha, FloatMatrix& beta, float *u, + octave_idx_type nrow_u, float *v, + octave_idx_type nrow_v, float *q, + octave_idx_type nrow_q, FloatMatrix& work, + octave_idx_type* iwork, octave_idx_type& info) + { + F77_XFCN (sggsvd, SGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), + F77_CONST_CHAR_ARG2 (&jobv, 1), + F77_CONST_CHAR_ARG2 (&jobq, 1), + m, n, p, k, l, tmp_dataA, m1, + tmp_dataB, p1, alpha.fortran_vec (), + beta.fortran_vec (), u, nrow_u, + v, nrow_v, q, nrow_q, work.fortran_vec (), + iwork, info + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1))); + } + + template <> + void + gsvd<ComplexMatrix>::ggsvd (char& jobu, char& jobv, char& jobq, + octave_idx_type m, octave_idx_type n, + octave_idx_type p, octave_idx_type& k, + octave_idx_type& l, Complex *tmp_dataA, + octave_idx_type m1, Complex *tmp_dataB, + octave_idx_type p1, Matrix& alpha, + Matrix& beta, Complex *u, + octave_idx_type nrow_u, + Complex *v, octave_idx_type nrow_v, Complex *q, + octave_idx_type nrow_q, ComplexMatrix& work, + octave_idx_type* iwork, octave_idx_type& info) + { + Matrix rwork(2*n, 1); + F77_XFCN (zggsvd, ZGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), + F77_CONST_CHAR_ARG2 (&jobv, 1), + F77_CONST_CHAR_ARG2 (&jobq, 1), + m, n, p, k, l, F77_DBLE_CMPLX_ARG (tmp_dataA), + m1, F77_DBLE_CMPLX_ARG (tmp_dataB), p1, + alpha.fortran_vec (), beta.fortran_vec (), + F77_DBLE_CMPLX_ARG (u), nrow_u, + F77_DBLE_CMPLX_ARG (v), nrow_v, + F77_DBLE_CMPLX_ARG (q), nrow_q, + F77_DBLE_CMPLX_ARG (work.fortran_vec ()), + rwork.fortran_vec (), iwork, info + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1))); + } + + template <> + void + gsvd<FloatComplexMatrix>::ggsvd (char& jobu, char& jobv, char& jobq, + octave_idx_type m, octave_idx_type n, + octave_idx_type p, octave_idx_type& k, + octave_idx_type& l, + FloatComplex *tmp_dataA, + octave_idx_type m1, + FloatComplex *tmp_dataB, + octave_idx_type p1, FloatMatrix& alpha, + FloatMatrix& beta, FloatComplex *u, + octave_idx_type nrow_u, FloatComplex *v, + octave_idx_type nrow_v, FloatComplex *q, + octave_idx_type nrow_q, + FloatComplexMatrix& work, + octave_idx_type* iwork, + octave_idx_type& info) + { + FloatMatrix rwork(2*n, 1); + F77_XFCN (cggsvd, CGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), + F77_CONST_CHAR_ARG2 (&jobv, 1), + F77_CONST_CHAR_ARG2 (&jobq, 1), + m, n, p, k, l, F77_CMPLX_ARG (tmp_dataA), m1, + F77_CMPLX_ARG (tmp_dataB), p1, + alpha.fortran_vec (), beta.fortran_vec (), + F77_CMPLX_ARG (u), nrow_u, + F77_CMPLX_ARG (v), nrow_v, + F77_CMPLX_ARG (q), nrow_q, + F77_CMPLX_ARG (work.fortran_vec ()), + rwork.fortran_vec (), iwork, info + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1) + F77_CHAR_ARG_LEN (1))); + } + + template <typename T> + T + gsvd<T>::left_singular_matrix_A (void) const + { + if (type == gsvd::Type::sigma_only) + { + (*current_liboctave_error_handler) + ("gsvd: U not computed because type == gsvd::sigma_only"); + return T (); + } + else + return left_smA; + } + + template <typename T> + T + gsvd<T>::left_singular_matrix_B (void) const + { + if (type == gsvd::Type::sigma_only) + { + (*current_liboctave_error_handler) + ("gsvd: V not computed because type == gsvd::sigma_only"); + return T (); + } + else + return left_smB; + } + + template <typename T> + T + gsvd<T>::right_singular_matrix (void) const + { + if (type == gsvd::Type::sigma_only) + { + (*current_liboctave_error_handler) + ("gsvd: X not computed because type == gsvd::sigma_only"); + return T (); + } + else + return right_sm; + } + + template <typename T> + T + gsvd<T>::R_matrix (void) const + { + if (type != gsvd::Type::std) + { + (*current_liboctave_error_handler) + ("gsvd: R not computed because type != gsvd::std"); + return T (); + } + else + return R; + } + + template <typename T> + gsvd<T>::gsvd (const T& a, const T& b, gsvd::Type gsvd_type) + { + octave_idx_type info; + + octave_idx_type m = a.rows (); + octave_idx_type n = a.cols (); + octave_idx_type p = b.rows (); + + T atmp = a; + P *tmp_dataA = atmp.fortran_vec (); + + T btmp = b; + P *tmp_dataB = btmp.fortran_vec (); + + char jobu = 'U'; + char jobv = 'V'; + char jobq = 'Q'; + + octave_idx_type nrow_u = m; + octave_idx_type nrow_v = p; + octave_idx_type nrow_q = n; + + octave_idx_type k, l; + + switch (gsvd_type) + { + case gsvd<T>::Type::sigma_only: + + // Note: for this case, both jobu and jobv should be 'N', but + // there seems to be a bug in dgesvd from Lapack V2.0. To + // demonstrate the bug, set both jobu and jobv to 'N' and find + // the singular values of [eye(3), eye(3)]. The result is + // [-sqrt(2), -sqrt(2), -sqrt(2)]. + // + // For Lapack 3.0, this problem seems to be fixed. + + jobu = 'N'; + jobv = 'N'; + jobq = 'N'; + nrow_u = nrow_v = nrow_q = 1; + break; + + default: + break; + } + + type = gsvd_type; + + if (! (jobu == 'N' || jobu == 'O')) + left_smA.resize (nrow_u, m); + + P *u = left_smA.fortran_vec (); + + if (! (jobv == 'N' || jobv == 'O')) + left_smB.resize (nrow_v, p); + + P *v = left_smB.fortran_vec (); + + if (! (jobq == 'N' || jobq == 'O')) + right_sm.resize (nrow_q, n); + + P *q = right_sm.fortran_vec (); + + octave_idx_type lwork = 3*n; + lwork = lwork > m ? lwork : m; + lwork = (lwork > p ? lwork : p) + n; + + T work (lwork, 1); + real_matrix alpha (n, 1); + real_matrix beta (n, 1); + + std::vector<octave_idx_type> iwork (n); + + gsvd<T>::ggsvd (jobu, jobv, jobq, m, n, p, k, l, + tmp_dataA, m, tmp_dataB, p, alpha, beta, u, + nrow_u, v, nrow_v, q, nrow_q, work, iwork.data (), info); + + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in *ggsvd"); + + if (info < 0) + (*current_liboctave_error_handler) ("*ggsvd.f: argument %d illegal", + -info); + else + { + if (info > 0) + (*current_liboctave_error_handler) + ("*ggsvd.f: Jacobi-type procedure failed to converge."); + else + { + octave_idx_type i, j; + + if (gsvd<T>::Type::std == gsvd_type) + { + R.resize(k+l, k+l); + int astart = n-k-l; + if (m - k - l >= 0) + { + astart = n-k-l; + // R is stored in A(1:K+L,N-K-L+1:N) + for (i = 0; i < k+l; i++) + for (j = 0; j < k+l; j++) + R.xelem (i, j) = atmp.xelem (i, astart + j); + } + else + { + // (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), + // ( 0 R22 R23 ) + + for (i = 0; i < m; i++) + for (j = 0; j < k+l; j++) + R.xelem (i, j) = atmp.xelem (i, astart + j); + // and R33 is stored in B(M-K+1:L,N+M-K-L+1:N) + for (i = k+l-1; i >=m; i--) + { + for (j = 0; j < m; j++) + R.xelem(i, j) = 0.0; + for (j = m; j < k+l; j++) + R.xelem (i, j) = btmp.xelem (i - k, astart + j); + } + } + } + + if (m-k-l >= 0) + { + // Fills in C and S + sigmaA.resize (l, l); + sigmaB.resize (l, l); + for (i = 0; i < l; i++) + { + sigmaA.dgxelem(i) = alpha.elem(k+i); + sigmaB.dgxelem(i) = beta.elem(k+i); + } + } + else + { + // Fills in C and S + sigmaA.resize (m-k, m-k); + sigmaB.resize (m-k, m-k); + for (i = 0; i < m-k; i++) + { + sigmaA.dgxelem(i) = alpha.elem(k+i); + sigmaB.dgxelem(i) = beta.elem(k+i); + } + } + } + } + } + + // Instantiations we need. + template class gsvd<Matrix>; + template class gsvd<FloatMatrix>; + template class gsvd<ComplexMatrix>; + template class gsvd<FloatComplexMatrix>; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/numeric/gsvd.h Thu Oct 27 22:13:53 2016 -0400 @@ -0,0 +1,102 @@ +// Copyright (C) 2016 Barbara Lócsi +// Copyright (C) 2006 Pascal Dupuis <Pascal.Dupuis@uclouvain.be> +// Copyright (C) 1996, 1997 John W. Eaton +// +// This program 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. +// +// This program 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 +// this program; if not, see <http://www.gnu.org/licenses/>. + +#if !defined (octave_gsvd_h) +#define octave_gsvd_h 1 + +#include "octave-config.h" + +namespace octave +{ + namespace math + { + template <typename T> + class + gsvd + { + public: + + enum class Type + { + std, + economy, + sigma_only + }; + + gsvd (void) : sigmaA (), sigmaB (), left_smA (), left_smB (), right_sm () + { } + + gsvd (const T& a, const T& b, + gsvd::Type gsvd_type = gsvd<T>::Type::economy); + + gsvd (const gsvd& a) + : type (a.type), + sigmaA (a.sigmaA), sigmaB (a.sigmaB), + left_smA (a.left_smA), left_smB (a.left_smB), right_sm (a.right_sm), + R(a.R) { } + + gsvd& operator = (const gsvd& a) + { + if (this != &a) + { + type = a.type; + sigmaA = a.sigmaA; + sigmaB = a.sigmaB; + left_smA = a.left_smA; + left_smB = a.left_smB; + right_sm = a.right_sm; + R = a.R; + } + + return *this; + } + + ~gsvd (void) { } + + typename T::real_diag_matrix_type + singular_values_A (void) const { return sigmaA; } + + typename T::real_diag_matrix_type + singular_values_B (void) const { return sigmaB; } + + T left_singular_matrix_A (void) const; + T left_singular_matrix_B (void) const; + + T right_singular_matrix (void) const; + T R_matrix (void) const; + + private: + typedef typename T::value_type P; + typedef typename T::real_matrix_type real_matrix; + + gsvd::Type type; + typename T::real_diag_matrix_type sigmaA, sigmaB; + T left_smA, left_smB; + T right_sm, R; + + void ggsvd (char& jobu, char& jobv, char& jobq, octave_idx_type m, + octave_idx_type n, octave_idx_type p, octave_idx_type& k, + octave_idx_type& l, P *tmp_dataA, octave_idx_type m1, + P *tmp_dataB, octave_idx_type p1, real_matrix& alpha, + real_matrix& beta, P *u, octave_idx_type nrow_u, P *v, + octave_idx_type nrow_v, P *q, octave_idx_type nrow_q, T& work, + octave_idx_type* iwork, octave_idx_type& info); + }; + } +} + +#endif
--- a/liboctave/numeric/lo-lapack-proto.h Thu Oct 27 22:02:40 2016 -0400 +++ b/liboctave/numeric/lo-lapack-proto.h Thu Oct 27 22:13:53 2016 -0400 @@ -807,6 +807,126 @@ F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL); + // GGSVD + + F77_RET_T + F77_FUNC (dggsvd, DGGSVD) + (F77_CONST_CHAR_ARG_DECL, // JOBU + F77_CONST_CHAR_ARG_DECL, // JOBV + F77_CONST_CHAR_ARG_DECL, // JOBQ + const F77_INT&, // M + const F77_INT&, // N + const F77_INT&, // P + F77_INT &, // K + F77_INT &, // L + F77_DBLE*, // A(LDA,N) + const F77_INT&, // LDA + F77_DBLE*, // B(LDB,N) + const F77_INT&, // LDB + F77_DBLE*, // ALPHA(N) + F77_DBLE*, // BETA(N) + F77_DBLE*, // U(LDU,M) + const F77_INT&, // LDU + F77_DBLE*, // V(LDV,P) + const F77_INT&, // LDV + F77_DBLE*, // Q(LDQ,N) + const F77_INT&, // LDQ + F77_DBLE*, // WORK + F77_INT*, // IWORK(N) + F77_INT& // INFO + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL); + + F77_RET_T + F77_FUNC (sggsvd, SGGSVD) + (F77_CONST_CHAR_ARG_DECL, // JOBU + F77_CONST_CHAR_ARG_DECL, // JOBV + F77_CONST_CHAR_ARG_DECL, // JOBQ + const F77_INT&, // M + const F77_INT&, // N + const F77_INT&, // P + F77_INT &, // K + F77_INT &, // L + F77_REAL*, // A + const F77_INT&, // LDA + F77_REAL*, // B + const F77_INT&, // LDB + F77_REAL*, // ALPHA + F77_REAL*, // BETA + F77_REAL*, // U + const F77_INT&, // LDU + F77_REAL*, // V + const F77_INT&, // LDV + F77_REAL*, // Q + const F77_INT&, // LDQ + F77_REAL*, // WORK + F77_INT*, // IWORK + F77_INT& // INFO + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL); + + F77_RET_T + F77_FUNC (zggsvd, ZGGSVD) + (F77_CONST_CHAR_ARG_DECL, // JOBU + F77_CONST_CHAR_ARG_DECL, // JOBV + F77_CONST_CHAR_ARG_DECL, // JOBQ + const F77_INT&, // M + const F77_INT&, // N + const F77_INT&, // P + F77_INT &, // K + F77_INT &, // L + F77_DBLE_CMPLX*, // A(LDA,N) + const F77_INT&, // LDA + F77_DBLE_CMPLX*, // B(LDB,N) + const F77_INT&, // LDB + F77_DBLE*, // ALPHA(N) + F77_DBLE*, // BETA(N) + F77_DBLE_CMPLX*, // U(LDU,M) + const F77_INT&, // LDU + F77_DBLE_CMPLX*, // V(LDV,P) + const F77_INT&, // LDV + F77_DBLE_CMPLX*, // Q(LDQ,N) + const F77_INT&, // LDQ + F77_DBLE_CMPLX*, // WORK + F77_DBLE*, // RWORK + F77_INT*, // IWORK(N) + F77_INT& // INFO + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL); + + F77_RET_T + F77_FUNC (cggsvd, CGGSVD) + (F77_CONST_CHAR_ARG_DECL, // JOBU + F77_CONST_CHAR_ARG_DECL, // JOBV + F77_CONST_CHAR_ARG_DECL, // JOBQ + const F77_INT&, // M + const F77_INT&, // N + const F77_INT&, // P + F77_INT &, // K + F77_INT &, // L + F77_CMPLX*, // A + const F77_INT&, // LDA + F77_CMPLX*, // B + const F77_INT&, // LDB + F77_REAL*, // ALPHA + F77_REAL*, // BETA + F77_CMPLX*, // U + const F77_INT&, // LDU + F77_CMPLX*, // V + const F77_INT&, // LDV + F77_CMPLX*, // Q + const F77_INT&, // LDQ + F77_CMPLX*, // WORK + F77_REAL*, // RWORK + F77_INT*, // IWORK + F77_INT& // INFO + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL + F77_CHAR_ARG_LEN_DECL); + // GTSV F77_RET_T
--- a/liboctave/numeric/module.mk Thu Oct 27 22:02:40 2016 -0400 +++ b/liboctave/numeric/module.mk Thu Oct 27 22:13:53 2016 -0400 @@ -18,6 +18,7 @@ liboctave/numeric/DASSL.h \ liboctave/numeric/DET.h \ liboctave/numeric/EIG.h \ + liboctave/numeric/gsvd.h \ liboctave/numeric/LSODE.h \ liboctave/numeric/ODE.h \ liboctave/numeric/ODEFunc.h \ @@ -69,6 +70,7 @@ liboctave/numeric/DASRT.cc \ liboctave/numeric/DASSL.cc \ liboctave/numeric/EIG.cc \ + liboctave/numeric/gsvd.cc \ liboctave/numeric/LSODE.cc \ liboctave/numeric/ODES.cc \ liboctave/numeric/Quad.cc \
--- a/liboctave/operators/mx-defs.h Thu Oct 27 22:02:40 2016 -0400 +++ b/liboctave/operators/mx-defs.h Thu Oct 27 22:13:53 2016 -0400 @@ -66,6 +66,8 @@ class EIG; +template <typename T> class gsvd; + template <typename T> class hess; template <typename T> class schur;
--- a/liboctave/operators/mx-ext.h Thu Oct 27 22:02:40 2016 -0400 +++ b/liboctave/operators/mx-ext.h Thu Oct 27 22:13:53 2016 -0400 @@ -57,6 +57,11 @@ #include "EIG.h" +// Result of a Generalized Singular Value Decomposition. + +#include "gsvd.h" + + // Result of an LU decomposition. #include "lu.h"
--- a/scripts/deprecated/bicubic.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,260 +0,0 @@ -## Copyright (C) 2005-2016 Hoxide Ma -## -## 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 {} {@var{zi} =} bicubic (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{extrapval}) -## -## @code{bicubic} is deprecated and will be removed in Octave version 4.4. -## Use @code{interp2 (@dots{}, "spline")} for the equivalent functionality. -## -## Return a matrix @var{zi} corresponding to the bicubic -## interpolations at @var{xi} and @var{yi} of the data supplied -## as @var{x}, @var{y} and @var{z}. Points outside the grid are set -## to @var{extrapval}. -## -## See @url{http://wiki.woodpecker.org.cn/moin/Octave/Bicubic} -## for further information. -## @seealso{interp2} -## @end deftypefn - -## Bicubic interpolation method. -## Author: Hoxide Ma <hoxide_dirac@yahoo.com.cn> - -## Deprecated in version 4.0 - -function zi = bicubic (x, y, z, xi, yi, extrapval, spline_alpha) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "bicubic is obsolete and will be removed from a future version of Octave, please use interp2 instead"); - endif - - if (nargin < 1 || nargin > 7) - print_usage (); - endif - - if (nargin == 7 && isscalar (spline_alpha)) - a = spline_alpha; - else - a = 0.5; - endif - - if (nargin < 6) - extrapval = NaN; - endif - - if (isa (x, "single") || isa (y, "single") || isa (z, "single") - || isa (xi, "single") || isa (yi, "single")) - myeps = eps ("single"); - else - myeps = eps (); - endif - - if (nargin <= 2) - ## bicubic (z) or bicubic (z, 2) - if (nargin == 1) - n = 1; - else - n = y; - endif - z = x; - x = []; - [rz, cz] = size (z); - s = linspace (1, cz, (cz-1) * pow2 (n) + 1); - t = linspace (1, rz, (rz-1) * pow2 (n) + 1); - elseif (nargin == 3) - if (! isvector (x) || ! isvector (y)) - error ("bicubic: XI and YI must be vector"); - endif - s = y; - t = z; - z = x; - [rz, cz] = size (z); - elseif (nargin == 5 || nargin == 6) - [rz, cz] = size (z); - if (isvector (x) && isvector (y)) - if (rz != length (y) || cz != length (x)) - error ("bicubic: length of X and Y must match the size of Z"); - endif - elseif (size_equal (x, y) && size_equal (x, z)) - x = x(1,:); - y = y(:,1); - else - error ("bicubic: X, Y and Z must be equal size matrices of same size"); - endif - - if (all (diff (x) < 0)) - flipx = true; - x = fliplr (x); - elseif (all (diff (x) > 0)) - flipx = false; - else - error ("bicubic:nonmonotonic", "bicubic: X values must be monotonic"); - endif - if (all (diff (y) < 0)) - flipy = true; - y = flipud (y); - elseif (all (diff (y) > 0)) - flipy = false; - else - error ("bicubic:nonmonotonic", "bicubic: Y values must be monotonic"); - endif - - ## Mark values outside the lookup table. - xfirst_ind = find (xi < x(1)); - xlast_ind = find (xi > x(cz)); - yfirst_ind = find (yi < y(1)); - ylast_ind = find (yi > y(rz)); - ## Set value outside the table preliminary to min max index. - xi(xfirst_ind) = x(1); - xi(xlast_ind) = x(cz); - yi(yfirst_ind) = y(1); - yi(ylast_ind) = y(rz); - - x = reshape (x, 1, cz); - x(cz) *= 1 + sign (x(cz)) * myeps; - if (x(cz) == 0) - x(cz) = myeps; - endif; - xi = reshape (xi, 1, length (xi)); - [m, i] = sort ([x, xi]); - o = cumsum (i <= cz); - xidx = o(find (i > cz)); - - y = reshape (y, rz, 1); - y(rz) *= 1 + sign (y(rz)) * myeps; - if (y(rz) == 0) - y(rz) = myeps; - endif; - yi = reshape (yi, length (yi), 1); - [m, i] = sort ([y; yi]); - o = cumsum (i <= rz); - yidx = o([find(i > rz)]); - - ## Set s and t used follow codes. - s = xidx + ((xi .- x(xidx)) ./ (x(xidx+1) .- x(xidx))); - t = yidx + ((yi - y(yidx)) ./ (y(yidx+1) - y(yidx))); - - if (flipx) - s = fliplr (s); - endif - if (flipy) - t = flipud (t); - endif - else - print_usage (); - endif - - if (rz < 3 || cz < 3) - error ("bicubic: Z at least a 3 by 3 matrices"); - endif - - inds = floor (s); - d = find (s == cz); - s = s - floor (s); - inds(d) = cz-1; - s(d) = 1.0; - - d = []; - indt = floor (t); - d = find (t == rz); - t = t - floor (t); - indt(d) = rz-1; - t(d) = 1.0; - d = []; - - p = zeros (size (z) + 2); - p(2:rz+1,2:cz+1) = z; - p(1,:) = (6*(1-a))*p(2,:) - 3*p(3,:) + (6*a-2)*p(4,:); - p(rz+2,:) = (6*(1-a))*p(rz+1,:) - 3*p(rz,:) + (6*a-2)*p(rz-1,:); - p(:,1) = (6*(1-a))*p(:,2) - 3*p(:,3) + (6*a-2)*p(:,4); - p(:,cz+2) = (6*(1-a))*p(:,cz+1) - 3*p(:,cz) + (6*a-2)*p(:,cz-1); - - ## Calculate the C1(t) C2(t) C3(t) C4(t) and C1(s) C2(s) C3(s) C4(s). - t2 = t.*t; - t3 = t2.*t; - - ct0 = -a .* t3 + (2 * a) .* t2 - a .* t ; # -a G0 - ct1 = (2-a) .* t3 + (-3+a) .* t2 + 1 ; # F0 - a G1 - ct2 = (a-2) .* t3 + (-2 *a + 3) .* t2 + a .* t ; # F1 + a G0 - ct3 = a .* t3 - a .* t2; # a G1 - t = []; t2 = []; t3 = []; - - s2 = s.*s; - s3 = s2.*s; - - cs0 = -a .* s3 + (2 * a) .* s2 - a .*s ; # -a G0 - cs1 = (2-a) .* s3 + (-3 + a) .* s2 + 1 ; # F0 - a G1 - cs2 = (a-2) .* s3 + (-2 *a + 3) .* s2 + a .*s ; # F1 + a G0 - cs3 = a .* s3 - a .* s2; # a G1 - s = []; s2 = []; s3 = []; - - cs0 = cs0([1,1,1,1],:); - cs1 = cs1([1,1,1,1],:); - cs2 = cs2([1,1,1,1],:); - cs3 = cs3([1,1,1,1],:); - - lent = length (ct0); - lens = columns (cs0); - zi = zeros (lent, lens); - - for i = 1:lent - it = indt(i); - int = [it, it+1, it+2, it+3]; - zi(i,:) = ([ct0(i),ct1(i),ct2(i),ct3(i)] - * (p(int,inds) .* cs0 + p(int,inds+1) .* cs1 - + p(int,inds+2) .* cs2 + p(int,inds+3) .* cs3)); - endfor - - ## Set points outside the table to extrapval. - if (! (isempty (xfirst_ind) && isempty (xlast_ind))) - zi(:, [xfirst_ind, xlast_ind]) = extrapval; - endif - if (! (isempty (yfirst_ind) && isempty (ylast_ind))) - zi([yfirst_ind; ylast_ind], :) = extrapval; - endif - -endfunction - - -%!demo -%! clf; -%! colormap ("default"); -%! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,4]+10; -%! y = [-10,-9,-8]; -%! xi = linspace (min (x), max (x), 17); -%! yi = linspace (min (y), max (y), 26)'; -%! mesh (xi, yi, bicubic (x,y,A,xi,yi)); -%! [x,y] = meshgrid (x,y); -%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; - -%!test -%! x = linspace (1, -1, 10); -%! [xx, yy] = meshgrid (x); -%! z = cos (6 * xx) + sin (6 * yy); -%! x = linspace (1, -1, 30); -%! [xx2, yy2] = meshgrid (x); -%! z1 = interp2 (xx, yy, z, xx2, yy2, "spline"); -%! z2 = interp2 (fliplr (xx), flipud (yy), fliplr (flipud(z)), -%! fliplr (xx2), flipud (yy2), "spline"); -%! z2 = fliplr (flipud (z2)); -%! assert (z1, z2, 100 * eps ()); -
--- a/scripts/deprecated/delaunay3.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -## Copyright (C) 1999-2016 Kai Habel -## -## 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 {} {@var{tetr} =} delaunay3 (@var{x}, @var{y}, @var{z}) -## @deftypefnx {} {@var{tetr} =} delaunay3 (@var{x}, @var{y}, @var{z}, @var{options}) -## -## @code{delaunay3} is deprecated and will be removed in Octave version 4.4. -## Please use @code{delaunay} in all new code. -## -## Compute the Delaunay triangulation for a 3-D set of points. -## The return value @var{tetr} is a set of tetrahedrons which satisfies the -## Delaunay circum-circle criterion, i.e., only a single data point from -## [@var{x}, @var{y}, @var{z}] is within the circum-circle of the defining -## tetrahedron. -## -## The set of tetrahedrons @var{tetr} is a matrix of size [n, 4]. Each -## row defines a tetrahedron and the four columns are the four vertices -## of the tetrahedron. The value of @code{@var{tetr}(i,j)} is an index into -## @var{x}, @var{y}, @var{z} for the location of the j-th vertex of the i-th -## tetrahedron. -## -## An optional fourth argument, which must be a string or cell array of -## strings, contains options passed to the underlying qhull command. See the -## documentation for the Qhull library for details -## @url{http://www.qhull.org/html/qh-quick.htm#options}. -## The default options are @code{@{"Qt", "Qbb", "Qc", "Qz"@}}. -## -## If @var{options} is not present or @code{[]} then the default arguments are -## used. Otherwise, @var{options} replaces the default argument list. -## To append user options to the defaults it is necessary to repeat the -## default arguments in @var{options}. Use a null string to pass no arguments. -## -## @seealso{delaunay, delaunayn, convhull, voronoi, tetramesh} -## @end deftypefn - -## Author: Kai Habel <kai.habel@gmx.de> - -## Deprecated in 4.0 - -function tetr = delaunay3 (x, y, z, options) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "delaunay3 is obsolete and will be removed from a future version of Octave, please use delaunay instead"); - endif - - if (nargin < 3 || nargin > 4) - print_usage (); - endif - - if (! (isvector (x) && isvector (y) && isvector (z) - && length (x) == length (y) && length (x) == length (z))) - error ("delaunay: X, Y, and Z must be the same size"); - elseif (nargin == 4 && ! (ischar (options) || iscellstr (options))) - error ("delaunay3: OPTIONS must be a string or cell array of strings"); - endif - - if (nargin == 3) - tetr = delaunayn ([x(:), y(:), z(:)]); - else - tetr = delaunayn ([x(:), y(:), z(:)], options); - endif - -endfunction - - -%!testif HAVE_QHULL -%! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; -%! assert (sortrows (sort (delaunay3 (x, y, z), 2)), [1,2,3,4;1,2,4,5]); - -## FIXME: Need input validation tests -
--- a/scripts/deprecated/dump_prefs.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -## Copyright (C) 1994-2016 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 {} {} dump_prefs () -## @deftypefnx {} {} dump_prefs (@var{fid}) -## -## @code{dump_prefs} is deprecated and will be removed in Octave version 4.4. -## Please use individual preference get/set routines in all new code. -## -## Dump the current settings of all user preferences to stdout in a format that -## can be parsed by Octave later. -## -## If the optional argument @var{fid} is given then the results are written to -## the file specified by file descriptor @var{fid}. -## @end deftypefn - -## Author: jwe - -## Deprecated in 4.0 - -function dump_prefs (fid) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "dump_prefs is obsolete and will be removed from a future version of Octave, recode using individual preference get/set routines"); - endif - - if (nargin > 1) - print_usage (); - endif - - if (nargin == 0) - fid = stdout; - endif - - ## FIXME: It would be nice to be able to get the list of built-in variables - ## directly from Octave so that we wouldn't have to remember to update it - ## each time the list of preference variables changes - - pref_list = {"EDITOR" - "EXEC_PATH" - "IMAGE_PATH" - "PAGER" - "PAGER_FLAGS" - "PS1" - "PS2" - "PS4" - "allow_noninteger_range_as_index" - "beep_on_error" - "built_in_docstrings_file" - "completion_append_char" - "confirm_recursive_rmdir" - "crash_dumps_octave_core" - "debug_java" - "debug_on_error" - "debug_on_interrupt" - "debug_on_warning" - "disable_diagonal_matrix" - "disable_permutation_matrix" - "disable_range" - "do_braindead_shortcircuit_evaluation" - "doc_cache_file" - "echo_executing_commands" - "fixed_point_format" - "gnuplot_binary" - "history_file" - "history_save" - "history_size" - "history_timestamp_format_string" - "ignore_function_time_stamp" - "info_file" - "info_program" - "java_matrix_autoconversion" - "java_unsigned_autoconversion" - "makeinfo_program" - "max_recursion_depth" - "missing_component_hook" - "missing_function_hook" - "octave_core_file_limit" - "octave_core_file_name" - "octave_core_file_options" - "optimize_subsasgn_calls" - "output_max_field_width" - "output_precision" - "page_output_immediately" - "page_screen_output" - "print_empty_dimensions" - "print_struct_array_contents" - "save_default_options" - "save_header_format_string" - "save_precision" - "sighup_dumps_octave_core" - "sigterm_dumps_octave_core" - "silent_functions" - "sparse_auto_mutate" - "split_long_rows" - "string_fill_char" - "struct_levels_to_print" - "suppress_verbose_help_message" - "texi_macros_file"}; - - for i = 1:rows (pref_list) - pref = pref_list{i}; - try - val = feval (pref); - if (isnumeric (val)) - val = sprintf ("%g", val); - endif - fprintf (fid, " %s = %s\n", pref, val); - catch - fprintf (fid, "# %s = <no value or error in displaying it>\n", pref); - end_try_catch - endfor - -endfunction - - -%!error dump_prefs (1,2) -
--- a/scripts/deprecated/find_dir_in_path.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -## Copyright (C) 2013-2016 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 {} {} find_dir_in_path (@var{dir}) -## @deftypefnx {} {} find_dir_in_path (@var{dir}, "all") -## This function has been deprecated. Use @code{dir_in_loadpath} instead. -## @seealso{dir_in_loadpath} -## @end deftypefn - -## Deprecated in version 4.0 - -function retval = find_dir_in_path (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "find_dir_in_path is obsolete and will be removed from a future version of Octave, please use dir_in_loadpath instead"); - endif - - retval = dir_in_loadpath (varargin{:}); - -endfunction -
--- a/scripts/deprecated/finite.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {} finite (@var{x}) -## -## @code{finite} is deprecated and will be removed in Octave version 4.4. -## Please use @code{isfinite} in all new code. -## -## Return a logical array which is true where the elements of @var{x} are -## finite values and false where they are not. -## For example: -## -## @example -## @group -## finite ([13, Inf, NA, NaN]) -## @result{} [ 1, 0, 0, 0 ] -## @end group -## @end example -## @seealso{isfinite, isinf, isnan, isna} -## @end deftypefn - -## Deprecated in version 4.0 - -function retval = finite (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "finite is obsolete and will be removed from a future version of Octave, please use isfinite instead"); - endif - - retval = isfinite (varargin{:}); - -endfunction -
--- a/scripts/deprecated/fmod.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {} fmod (@var{x}, @var{y}) -## -## @code{fmod} is deprecated and will be removed in Octave version 4.4. -## Please use @code{rem} in all new code. -## -## Return the remainder of the division @code{@var{x} / @var{y}}, computed -## using the expression -## -## @example -## x - y .* fix (x ./ y) -## @end example -## -## An error message is printed if the dimensions of the arguments do not -## agree, or if either of the arguments is complex. -## @seealso{rem, mod} -## @end deftypefn - -## Deprecated in version 4.0 - -function retval = fmod (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "fmod is obsolete and will be removed from a future version of Octave, please use rem instead"); - endif - - retval = rem (varargin{:}); - -endfunction -
--- a/scripts/deprecated/fnmatch.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {} fnmatch (@var{pattern}, @var{string}) -## -## @code{fnmatch} is deprecated and will be removed in Octave version 4.4. -## Please use @code{glob} or @code{regexp} in all new code. -## -## Return true or false for each element of @var{string} that matches any of -## the elements of the string array @var{pattern}, using the rules of -## filename pattern matching. For example: -## -## @example -## @group -## fnmatch (\"a*b\", @{\"ab\"; \"axyzb\"; \"xyzab\"@}) -## @result{} [ 1; 1; 0 ] -## @end group -## @end example -## @seealso{glob, regexp} -## @end deftypefn - -## Deprecated in version 4.0 - -function retval = fnmatch (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "fnmatch is obsolete and will be removed from a future version of Octave, please use glob or regexp instead"); - endif - - retval = __fnmatch__ (varargin{:}); - -endfunction -
--- a/scripts/deprecated/gmap40.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -## Copyright (C) 2007-2016 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 {} {@var{map} =} gmap40 () -## @deftypefnx {} {@var{map} =} gmap40 (@var{n}) -## -## @code{gmap40} is deprecated and will be removed in Octave version 4.4. -## -## Create color colormap. The colormap consists of red, green, blue, yellow, -## magenta and cyan. -## -## This colormap is specifically designed for users of gnuplot 4.0 where these -## 6 colors are the allowable ones for patch objects. -## -## The argument @var{n} must be a scalar. -## If unspecified, a length of 6 is assumed. Larger values of @var{n} result -## in a repetition of the above colors. -## @seealso{colormap} -## @end deftypefn - -## Deprecated in 4.0 - -function map = gmap40 (n = rows (colormap ())) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "gmap40 is obsolete and will be removed from a future version of Octave"); - endif - - if (nargin > 1) - print_usage (); - elseif (! isscalar (n)) - error ("gmap40: N must be a scalar"); - endif - - if (n > 0) - C = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1]; - map = C(rem (0:(n-1), 6) + 1, :); - else - map = zeros (0, 3); - endif - -endfunction - - -%!demo -%! ## Show the 'gmap40' colormap as an image -%! image (1:6, linspace (0, 1, 6), repmat ((1:6)', 1, 6)); -%! axis ([1, 6, 0, 1], "ticy", "xy"); -%! colormap (gmap40 (6)); -
--- a/scripts/deprecated/loadaudio.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -## Copyright (C) 1995-2016 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 {} {} loadaudio (@var{name}, @var{ext}, @var{bps}) -## -## @code{loadaudio} is deprecated and will be removed in Octave version 4.4. -## Please use @code{audioread} in all new code. -## -## Load audio data from the file @file{@var{name}.@var{ext}} into the -## vector @var{x}. -## -## The extension @var{ext} determines how the data in the audio file is -## interpreted; the extensions @file{lin} (default) and @file{raw} -## correspond to linear, the extensions @file{au}, @file{mu}, or @file{snd} -## to mu-law encoding. -## -## The argument @var{bps} can be either 8 (default) or 16, and specifies -## the number of bits per sample used in the audio file. -## @seealso{lin2mu, mu2lin, saveaudio, playaudio, setaudio, record} -## @end deftypefn - - -## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> -## Created: 10 April 1994 -## Adapted-By: jwe - -function X = loadaudio (name, ext, bps) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "loadaudio is obsolete and will be removed from a future version of Octave, please use audioread instead"); - endif - - if (nargin == 0 || nargin > 3) - print_usage (); - endif - - if (nargin == 1) - ext = "lin"; - endif - - if (nargin < 3) - bps = 8; - elseif (bps != 8 && bps != 16) - error ("loadaudio: BPS must be either 8 or 16"); - endif - - name = [name, ".", ext]; - num = fopen (name, "rb"); - - if (strcmp (ext, "lin") || strcmp (ext, "raw") || strcmp (ext, "pcm")) - if (bps == 8) - [Y, c] = fread (num, inf, "uchar"); - X = Y - 127; - else - [X, c] = fread (num, inf, "short"); - endif - elseif (strcmp (ext, "mu") || strcmp (ext, "au") - || strcmp (ext, "snd") || strcmp (ext, "ul")) - [Y, c] = fread (num, inf, "uchar"); - ## remove file header - m = find (Y(1:64) == 0, 1, "last"); - if (! isempty (m)) - Y(1:m) = []; - endif - X = mu2lin (Y, bps); - else - fclose (num); - error ("loadaudio: unsupported extension"); - endif - - fclose (num); - -endfunction -
--- a/scripts/deprecated/luinc.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, '0') -## @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{droptol}) -## @deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{opts}) -## -## @code{luinc} is deprecated and will be removed in Octave version 4.4. -## Please use @code{ilu} or @code{ichol} in all new code. -## -## Produce the incomplete LU@tie{}factorization of the sparse matrix @var{A}. -## Two types of incomplete factorization are possible, and the type -## is determined by the second argument to @code{luinc}. -## -## Called with a second argument of @qcode{'0'}, the zero-level incomplete -## LU@tie{}factorization is produced. This creates a factorization of @var{A} -## where the position of the nonzero arguments correspond to the same -## positions as in the matrix @var{A}. -## -## Alternatively, the fill-in of the incomplete LU@tie{}factorization can -## be controlled through the variable @var{droptol} or the structure -## @var{opts}. The @sc{umfpack} multifrontal factorization code by Tim A. -## Davis is used for the incomplete LU@tie{}factorization, (availability -## @url{http://www.cise.ufl.edu/research/sparse/umfpack/}) -## -## @var{droptol} determines the values below which the values in the -## LU@tie{} factorization are dropped and replaced by zero. It must be a -## positive scalar, and any values in the factorization whose absolute value -## are less than this value are dropped, expect if leaving them increase the -## sparsity of the matrix. Setting @var{droptol} to zero results in a complete -## LU@tie{}factorization which is the default. -## -## @var{opts} is a structure containing one or more of the fields -## -## @table @code -## @item droptol -## The drop tolerance as above. If @var{opts} only contains @code{droptol} -## then this is equivalent to using the variable @var{droptol}. -## -## @item milu -## A logical variable flagging whether to use the modified incomplete -## LU@tie{} factorization. In the case that @code{milu} is true, the dropped -## values are subtracted from the diagonal of the matrix @var{U} of the -## factorization. The default is @code{false}. -## -## @item udiag -## A logical variable that flags whether zero elements on the diagonal of -## @var{U} should be replaced with @var{droptol} to attempt to avoid singular -## factors. The default is @code{false}. -## -## @item thresh -## Defines the pivot threshold in the interval [0,1]. Values outside that -## range are ignored. -## @end table -## -## All other fields in @var{opts} are ignored. The outputs from @code{luinc} -## are the same as for @code{lu}. -## -## Given the string argument @qcode{"vector"}, @code{luinc} returns the -## values of @var{p} @var{q} as vector values. -## @seealso{ilu, ichol, lu, sparse} -## @end deftypefn - -## Deprecated in version 4.0 - -function [L, U, P, Q] = luinc (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "luinc is obsolete and will be removed from a future version of Octave, please use ilu or ichol instead"); - endif - - [L, U, P, Q] = __luinc__ (varargin{:}); - -endfunction - - -%!testif HAVE_UMFPACK -%! a = sparse ([1,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]); -%! [l,u] = luinc (a, 1e-10); -%! assert (l*u, sparse ([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10); -%! opts.droptol = 1e-10; -%! [l,u] = luinc (a, opts); -%! assert (l*u, sparse ([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10); - -%!testif HAVE_UMFPACK -%! a = sparse ([1i,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]); -%! [l,u] = luinc (a, 1e-10); -%! assert (l*u, sparse ([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10); -%! opts.droptol = 1e-10; -%! [l,u] = luinc (a, opts); -%! assert (l*u, sparse ([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10); -
--- a/scripts/deprecated/module.mk Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/deprecated/module.mk Thu Oct 27 22:13:53 2016 -0400 @@ -1,34 +1,16 @@ FCN_FILE_DIRS += scripts/deprecated scripts_deprecated_FCN_FILES = \ - scripts/deprecated/bicubic.m \ scripts/deprecated/bitmax.m \ scripts/deprecated/comma.m \ - scripts/deprecated/delaunay3.m \ - scripts/deprecated/dump_prefs.m \ - scripts/deprecated/find_dir_in_path.m \ - scripts/deprecated/finite.m \ - scripts/deprecated/fmod.m \ - scripts/deprecated/fnmatch.m \ - scripts/deprecated/gmap40.m \ scripts/deprecated/isstr.m \ - scripts/deprecated/loadaudio.m \ - scripts/deprecated/luinc.m \ scripts/deprecated/mahalanobis.m \ scripts/deprecated/md5sum.m \ - scripts/deprecated/mouse_wheel_zoom.m \ - scripts/deprecated/nfields.m \ scripts/deprecated/octave_config_info.m \ - scripts/deprecated/octave_tmp_file_name.m \ scripts/deprecated/onenormest.m \ scripts/deprecated/paren.m \ - scripts/deprecated/playaudio.m \ - scripts/deprecated/saveaudio.m \ scripts/deprecated/semicolon.m \ - scripts/deprecated/setaudio.m \ scripts/deprecated/sleep.m \ - scripts/deprecated/syl.m \ - scripts/deprecated/usage.m \ scripts/deprecated/usleep.m \ scripts/deprecated/wavread.m \ scripts/deprecated/wavwrite.m
--- a/scripts/deprecated/mouse_wheel_zoom.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -## Copyright (C) 2007-2016 Shai Ayal -## -## 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 {} {@var{old_val} =} mouse_wheel_zoom (@var{new_val}) -## Query or set the mouse wheel zoom factor. -## -## The zoom factor is a number in the range (0,1) which is the -## percentage of the current axis limits that will be used when zooming. -## For example, if the current x-axis limits are [0, 50] and -## @code{mouse_wheel_zoom} is 0.4 (40%), then a zoom operation will -## change the limits by 20. -#### @end deftypefn - -## Deprecated in 4.0 - -function retval = mouse_wheel_zoom (val) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "mouse_wheel_zoom is obsolete and will be removed from a future version of Octave, please use the mousehweelzoom axes property instead"); - endif - - if (nargin != 1) - print_usage (); - endif - - fig = get (0, "currentfigure"); - if (isempty (fig)) - retval = get (0, "defaultaxesmousewheelzoom"); - set (0, "defaultaxesmousewheelzoom", val); - else - retval = get (gca, "mousewheelzoom"); - set (gca, "mousewheelzoom", val); - endif - -endfunction -
--- a/scripts/deprecated/nfields.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -## Copyright (C) 2014-2016 Rik Wehbring -## -## 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 {} {} nfields (@var{s}) -## Return the number of fields of the structure @var{s}. -## -## @strong{Warning:} @code{nfields} is scheduled for removal in version 4.4. -## Use @code{numfields} instead. -## @seealso{numfields, fieldnames} -## @end deftypefn - -## Deprecated in 4.0 - -function retval = nfields (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "nfields is obsolete and will be removed from a future version of Octave; please use numfields instead"); - endif - - if (nargin < 1) - print_usage (); - endif - - retval = numfields (varargin{:}); - -endfunction -
--- a/scripts/deprecated/octave_tmp_file_name.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {@var{fname} =} octave_tmp_file_name () -## @deftypefnx {} {@var{fname} =} octave_tmp_file_name (@var{dir}) -## @deftypefnx {} {@var{fname} =} octave_tmp_file_name (@var{dir}, @var{prefix}) -## -## @code{octave_tmp_file_name} is deprecated and will be removed in Octave -## version 4.4. Use @code{tempname} for equivalent functionality. -## -## Return a unique temporary filename as a string. -## -## If @var{prefix} is omitted, a value of @qcode{"oct-"} is used. -## If @var{dir} is also omitted, the default directory for temporary files -## (@code{P_tmpdir} is used. If @var{dir} is provided, it must exist, -## otherwise the default directory for temporary files is used. -## @seealso{tempname, tmpnam, mkstemp, tempdir, P_tmpdir, tmpfile} -## @end deftypefn - -## Deprecated in version 4.0 - -function filename = octave_tmp_file_name (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "octave_tmp_file_name is obsolete and will be removed from a future version of Octave, please use tempname instead"); - endif - - filename = tmpnam (varargin{:}); - -endfunction - - -%!assert (1) -
--- a/scripts/deprecated/playaudio.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -## Copyright (C) 1995-2016 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 {} {} playaudio (@var{name}, @var{ext}) -## @deftypefnx {} {} playaudio (@var{x}) -## -## @code{playaudio} is deprecated and will be removed in Octave version 4.4. -## Please use @code{audioplayer} in all new code. -## -## Play the audio file @file{@var{name}.@var{ext}} or the audio data -## stored in the vector @var{x}. -## @seealso{lin2mu, mu2lin, loadaudio, saveaudio, setaudio, record} -## @end deftypefn - -## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> -## Created: 11 April 1994 -## Adapted-By: jwe - -function playaudio (name, ext) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "playaudio is obsolete and will be removed from a future version of Octave, please use audioplayer instead"); - endif - - if (nargin < 1 || nargin > 2) - print_usage (); - endif - - if (nargin == 1 && isnumeric (name)) - ## play a vector - if (! isvector (name)) - error ("playaudio: X must be a vector"); - endif - X = name(:) + 127; - unwind_protect - file = tempname (); - fid = fopen (file, "wb"); - fwrite (fid, X, "uchar"); - fclose (fid); - [status, out] = system (sprintf ('cat "%s" > /dev/dsp', file)); - if (status != 0) - system (sprintf ("paplay --raw \"%s\"", file)); - endif - unwind_protect_cleanup - unlink (file); - end_unwind_protect - elseif (nargin >= 1 && ischar (name)) - ## play a file - if (nargin == 1) - name = [name ".lin"]; - elseif (nargin == 2) - name = [name "." ext]; - endif - if (any (strcmp (ext, {"lin", "raw"}))) - [status, out] = system (sprintf ('cat "%s" > /dev/dsp', name)); - if (status != 0) - system (sprintf ('paplay --raw "%s"', name)); - endif - elseif (any (strcmp (ext, {"mu", "au" "snd", "ul"}))) - [status, out] = system (sprintf ('cat "%s" > /dev/audio', name)); - if (status != 0) - system (sprintf ('paplay "%s"', name)); - endif - else - error ("playaudio: unsupported extension '%s'", ext); - endif - else - print_usage (); - endif - -endfunction - - -## Test input validation -%!error playaudio () -%!error playaudio (1,2,3) -%!error <X must be a vector> playaudio (magic (3)) -%!error <unsupported extension> playaudio ("file", "abc") -%!error playaudio ({"abc"}) -
--- a/scripts/deprecated/saveaudio.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -## Copyright (C) 1995-2016 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 {} {} saveaudio (@var{name}, @var{x}, @var{ext}, @var{bps}) -## -## @code{saveaudio} is deprecated and will be removed in Octave version 4.4. -## Please use @code{audiowrite} in all new code. -## -## Save a vector @var{x} of audio data to the file -## @file{@var{name}.@var{ext}}. The optional parameters @var{ext} and -## @var{bps} determine the encoding and the number of bits per sample used -## in the audio file (see @code{loadaudio}); defaults are @file{lin} and -## 8, respectively. -## @seealso{lin2mu, mu2lin, loadaudio, playaudio, setaudio, record} -## @end deftypefn - -## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> -## Created: 5 September 1994 -## Adapted-By: jwe - -function saveaudio (name, x, ext, bps) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "saveaudio is obsolete and will be removed from a future version of Octave, please use audiowrite instead"); - endif - - if (nargin < 2 || nargin > 4) - print_usage (); - endif - - if (nargin == 2) - ext = "lin"; - endif - - if (nargin < 4) - bps = 8; - elseif (bps != 8 && bps != 16) - error ("saveaudio: BPS must be either 8 or 16"); - endif - - [nr, nc] = size (x); - if (nc != 1) - if (nr == 1) - x = x'; - nr = nc; - else - error ("saveaudio: X must be a vector"); - endif - endif - - num = fopen ([name, ".", ext], "wb"); - - if (strcmp (ext, "lin") || strcmp (ext, "raw")) - if (bps == 8) - ld = max (abs (x)); - if (ld > 127) # convert 16 to 8 bit - if (ld < 16384) - sc = 64 / ld; - else - sc = 1 / 256; - endif - x = fix (x * sc); - endif - x = x + 127; - c = fwrite (num, x, "uchar"); - else - c = fwrite (num, x, "short"); - endif - elseif (strcmp (ext, "mu") || strcmp (ext, "au") - || strcmp (ext, "snd") || strcmp (ext, "ul")) - y = lin2mu (x); - c = fwrite (num, y, "uchar"); - else - fclose (num); - error ("saveaudio: unsupported extension"); - endif - - fclose (num); - -endfunction -
--- a/scripts/deprecated/setaudio.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -## Copyright (C) 1995-2016 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 {} {} setaudio () -## @deftypefnx {} {} setaudio (@var{w_type}) -## @deftypefnx {} {} setaudio (@var{w_type}, @var{value}) -## -## @code{setaudio} is deprecated and will be removed in Octave version 4.4. -## Please scale the audio signal in all new code or use the operating system's -## native tools to adjust audio input and output levels. -## -## Execute the shell command @samp{mixer}, possibly with optional -## arguments @var{w_type} and @var{value}. -## @end deftypefn - -## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> -## Created: 5 October 1994 -## Adapted-By: jwe - -function setaudio (w_type, value) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "setaudio is obsolete and will be removed from a future version of Octave, please scale the audio signal instead"); - endif - - if (nargin == 0) - system ("mixer"); - elseif (nargin == 1) - system (sprintf ("mixer %s", w_type)); - elseif (nargin == 2) - system (sprintf ("mixer %s %d", w_type, value)); - else - print_usage (); - endif - -endfunction -
--- a/scripts/deprecated/syl.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {@var{x} =} syl (@var{A}, @var{B}, @var{C}) -## -## @code{syl} is deprecated and will be removed in Octave version 4.4. -## Use @code{sylvester} for the equivalent functionality. -## -## Solve the Sylvester equation -## @tex -## $$ -## A X + X B + C = 0 -## $$ -## @end tex -## @ifnottex -## -## @example -## A X + X B + C = 0 -## @end example -## -## @end ifnottex -## using standard @sc{lapack} subroutines. For example: -## -## @example -## @group -## syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12]) -## @result{} [ -0.50000, -0.66667; -0.66667, -0.50000 ] -## @end group -## @end example -## @end deftypefn - -## Deprecated in version 4.0 - -function x = syl (A, B, C) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "syl is obsolete and will be removed from a future version of Octave, please use sylvester instead"); - endif - - if (nargin != 3 || nargout > 1) - print_usage (); - endif - - x = -sylvester (A, B, C); - -endfunction -
--- a/scripts/deprecated/usage.m Thu Oct 27 22:02:40 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -## Copyright (C) 2014-2016 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 {} {} usage (@var{msg}) -## -## @code{usage} is deprecated and will be removed in Octave version 4.4. -## Please use @code{print_usage} in all new code. -## -## Print the message @var{msg}, prefixed by the string @samp{usage: }, and -## set Octave's internal error state such that control will return to the -## top level without evaluating any more commands. This is useful for -## aborting from functions. -## -## After @code{usage} is evaluated, Octave will print a traceback of all -## the function calls leading to the usage message. -## -## You should use this function for reporting problems errors that result -## from an improper call to a function, such as calling a function with an -## incorrect number of arguments, or with arguments of the wrong type. For -## example, most functions distributed with Octave begin with code like -## this -## -## @example -## @group -## if (nargin != 2) -## usage (\"foo (a, b)\"); -## endif -## @end group -## @end example -## -## @noindent -## to check for the proper number of arguments. -## @seealso{print_usage} -## @end deftypefn - -## Deprecated in version 4.0 - -function retval = usage (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "usage is obsolete and will be removed from a future version of Octave, please use print_usage instead"); - endif - - retval = __usage__ (varargin{:}); - -endfunction -
--- a/scripts/help/__unimplemented__.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/help/__unimplemented__.m Thu Oct 27 22:13:53 2016 -0400 @@ -49,11 +49,6 @@ txt = ["exifread is deprecated. " ... "The functionality is available in the imfinfo function."]; - case "gsvd" - txt = ["gsvd is not currently part of core Octave. ", ... - "See the linear-algebra package at ", ... - "@url{http://octave.sourceforge.net/linear-algebra/}."]; - case "funm" txt = ["funm is not currently part of core Octave. ", ... "See the linear-algebra package at ", ... @@ -657,7 +652,6 @@ "graph", "graymon", "griddedInterpolant", - "gsvd", "guide", "h5create", "h5disp",
--- a/scripts/io/strread.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/io/strread.m Thu Oct 27 22:13:53 2016 -0400 @@ -174,7 +174,7 @@ ## ## @table @asis ## @item last character = @qcode{"@xbackslashchar{}n"} -## Data columns are padded with empty fields or Nan so that all columns have +## Data columns are padded with empty fields or NaN so that all columns have ## equal length ## ## @item last character is not @qcode{"@xbackslashchar{}n"}
--- a/scripts/ode/odeplot.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/ode/odeplot.m Thu Oct 27 22:13:53 2016 -0400 @@ -75,16 +75,14 @@ ## No input argument checking is done for better performance persistent hlines num_lines told yold; - persistent idx = 1; # Don't remove. Required for Octave parser. ## odeplot never stops the integration stop_solve = false; if (isempty (flag)) ## Default case, plot and return a value - idx += 1; - told(idx,1) = t(1,1); - yold(:,idx) = y(:,1); + told = [told; t(:)]; + yold = [yold, y]; for i = 1:num_lines set (hlines(i), "xdata", told, "ydata", yold(i,:)); endfor @@ -99,7 +97,7 @@ told = t(1); yold = y(:,1); figure (); - hlines = plot (told, yold, "-", "marker", ".", "markersize", 9); + hlines = plot (told, yold, "o-"); xlim ([t(1), t(end)]); # Fix limits which also speeds up plotting num_lines = numel (hlines);
--- a/scripts/plot/appearance/annotation.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/appearance/annotation.m Thu Oct 27 22:13:53 2016 -0400 @@ -268,7 +268,7 @@ ## hidden property to store figure size in absolute (points) ## coordinates - addproperty ("figsize_points", hax, "axesxmtick", []); + addproperty ("figsize_points", hax, "axesxminortickvalues", []); update_figsize_points (hf, {}, hax);
--- a/scripts/plot/appearance/legend.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/appearance/legend.m Thu Oct 27 22:13:53 2016 -0400 @@ -1364,11 +1364,20 @@ %!demo %! clf; +%! subplot (2,1,1); %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; %! bar (rand_2x3_data1); %! ylim ([0 1.0]); %! title ("legend() works for bar graphs (hggroups)"); -%! legend ({"1st Bar", "2nd Bar", "3rd Bar"}); +%! legend ({"1st Bar", "2nd Bar", "3rd Bar"}, "location", "northwest"); +%! subplot (2,1,2); +%! x = linspace (0, 10, 20); +%! stem (x, 0.5+x.*rand (size (x))/max (x), "markeredgecolor", [0 0.7 0]); +%! hold on; +%! stem (x+10/(2*20), x.*(1.0+rand (size (x)))/max (x)); +%! xlim ([0 10+10/(2*20)]); +%! title ("legend() works for stem plots (hggroups)"); +%! legend ({"Multicolor", "Unicolor"}, "location", "northwest"); %!demo %! clf;
--- a/scripts/plot/appearance/whitebg.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/appearance/whitebg.m Thu Oct 27 22:13:53 2016 -0400 @@ -20,31 +20,55 @@ ## @deftypefn {} {} whitebg () ## @deftypefnx {} {} whitebg (@var{color}) ## @deftypefnx {} {} whitebg ("none") -## @deftypefnx {} {} whitebg (@var{hfig}, @dots{}) +## @deftypefnx {} {} whitebg (@var{hfig}) +## @deftypefnx {} {} whitebg (@var{hfig}, @var{color}) +## @deftypefnx {} {} whitebg (@var{hfig}, "none") ## Invert the colors in the current color scheme. ## -## The root properties are also inverted such that all subsequent plot use the -## new color scheme. +## The root properties are also inverted such that all subsequent plots will +## use the new color scheme. ## ## If the optional argument @var{color} is present then the background color ## is set to @var{color} rather than inverted. @var{color} may be a string ## representing one of the eight known colors or an RGB triplet. The special -## string argument @qcode{"none"} restores the plot to the default colors. +## string argument @qcode{"none"} restores the plot to the factory default +## colors. +## +## If the first argument @var{hfig} is a figure handle or list of figure +## handles, then operate on these figures rather than the current figure +## returned by @code{gcf}. The root properties will not be changed unless 0 +## is in the list of figures. ## -## If the first argument @var{hfig} is a figure handle, then operate on -## this figure rather than the current figure returned by @code{gcf}. The -## root properties will not be changed. +## Programming Note: @code{whitebg} operates by changing the color properties +## of the children of the specified figures. Only objects with a single color +## are affected. For example, a patch with a single @qcode{"FaceColor"} will +## be changed, but a patch with shading (@qcode{"interp"}) will not be +## modified. For inversion, the new color is simply the inversion in RGB +## space: @code{@var{cnew} = [1-@var{R} 1-@var{G} 1-@var{B}]}. When a color +## is specified, the axes and figure are set to the new color, and the color +## of child objects are then adjusted to have some contrast (visibility) +## against the new background. ## @seealso{reset, get, set} ## @end deftypefn +## FIXME: It's not clear whether Matlab also changes color properties +## of the figure object itself, or only the children. However, visually, +## it looks better to change the figure along with the axes background. + function whitebg (varargin) + if (nargin > 2) + print_usage (); + endif + h = 0; color = NaN; + have_fig = false; - if (nargin > 0 && nargin < 3) - if (ishandle (varargin{1})) + if (nargin > 0) + if (all (ishandle (varargin{1}))) h = varargin{1}; + have_fig = true; if (nargin == 2) color = varargin{2}; endif @@ -53,117 +77,175 @@ else print_usage (); endif - elseif (nargin != 0) - print_usage (); endif - typ = get (h, "type"); - - if (strcmp (typ, "root")) - isroot = true; + if (! have_fig) fig = gcf (); - elseif (strcmp (typ, "figure")) - isroot = false; - fig = h; + do_root = true; + elseif (all (isfigure (h) | h == 0)) + fig = h(h != 0); + do_root = any (h == 0); else - error ("whitebg: HFIF must be a valid figure handle"); + error ("whitebg: HFIG must be a valid figure handle"); endif - axes = findall (fig, "type", "axes"); if (isnan (color)) - ## Root figure. Set the default axes and figure properties so that - ## subsequent plots have the new color scheme. - if (isroot) + if (do_root) + ## Set the default axes and figure properties on root + ## so that subsequent plots have the new color scheme fac = get (0, "factory"); fields = fieldnames (fac); - fieldindex = intersect (find (! cellfun ("isempty", regexp (fields, 'color'))), union (find (! cellfun ("isempty", regexp (fields, 'factoryaxes.*'))), find (! cellfun ("isempty", regexp (fields, 'factoryfigure.*'))))); + idx = ! cellfun ("isempty", regexp (fields, + '^factory(axes|figure).*color$')); - ## Check whether the factory value has been replaced - for nf = 1 : numel (fieldindex); - defaultfield = strrep (fields{fieldindex(nf)}, "factory", "default"); + ## Use default value in place of factory value if specified. + for field = fields(idx)' + defaultfield = strrep (field{1}, "factory", "default"); try - defaultvalue = 1 - get (0, defaultfield{n}); + defaultvalue = 1 - get (0, defaultfield); catch - field = fields{fieldindex(nf)}; - defaultvalue = 1 - subsref (fac, struct ("type", ".", "subs", field)); + defaultvalue = 1 - fac.(field{1}); end_try_catch set (0, defaultfield, defaultvalue); endfor endif - ## Load all objects which qualify for being searched. - handles = fig; - h = fig; - while (numel (handles)) - children = []; - for n = 1 : numel (handles) - children = union (children, get (handles(n), "children")); - endfor - handles = children; - h = union (h, children); - endwhile + ## The sort is necessary so that child legend objects are acted on + ## before the legend axes object. + hlist = sort (findobj (fig)); - for nh = 1 : numel (h) - p = get (h (nh)); - fields = fieldnames (p); - fieldindex = find (! cellfun ("isempty", regexp (fields, 'color'))); - if (numel (fieldindex)) - for nf = 1 : numel (fieldindex); - field = fields{fieldindex(nf)}; - c = subsref (p, struct ("type", ".", "subs", field)); - if (! ischar (c) && columns (c) == 3) - set (h (nh), field, 1 - c); - endif - endfor + for h = hlist' + props = get (h); + fields = fieldnames (props); + ## Find all fields with the word color in them and invert. + idx = find (! cellfun ("isempty", regexp (fields, 'color$'))); + for field = fields(idx)'; + c = props.(field{1}); + if (! ischar (c) && columns (c) == 3) + set (h, field{1}, 1 - c); + endif + endfor + endfor + + else # 2nd argument such as a color or "none" + + if (! strcmp (color, "none")) + ## Set the specified color on the figure and all axes objects + hlist = [fig; findobj(fig, "type", "axes")]; + set (hlist, "color", color); + if (do_root) + defs = get (0, "default"); + if (isfield (defs, "defaultaxescolor") + && strcmp (defs.defaultaxescolor, "none")) + set (0, "defaultaxescolor", color); + endif endif - ## If h(nh) is a figure or axes invert default color properties - typ = subsref (p, struct ("type", ".", "subs", "type")); - if (strcmp (typ, "axes") || strcmp (typ, "figure")) - def = get (h (nh), "default"); - fields = fieldnames (def); - if (! isempty (fields)) - fieldindex = find (! cellfun ("isempty", regexp (fields, 'color'))); - for nf = 1 : numel (fieldindex) - defaultfield = fields{fieldindex(nf)}; - defaultvalue = ... - 1 - subsref (def, struct ("type", ".", "subs", defaultfield)); - set (h (nh), defaultfield, defaultvalue); - endfor - endif + ## Adjust colors of remaining objects to have some contrast + bg = rgb2hsv (get (fig, "color")); + ## List of children without the figure and axes objects already changed + hlist = setdiff (findobj (fig), hlist); + for h = hlist' + props = get (h); + fields = fieldnames (props); + ## Find all fields with the word color in them and adjust HSV. + idx = find (! cellfun ("isempty", regexp (fields, 'color$'))); + for field = fields(idx)'; + c = props.(field{1}); + if (! ischar (c) && columns (c) == 3) + set (h, field{1}, calc_contrast_color (bg, c)); + endif + endfor + endfor + + else + ## Reset colors to factory defaults + if (do_root) + fac = get (0, "factory"); + fields = fieldnames (fac); + idx = ! cellfun ("isempty", regexp (fields, + '^factory(axes|figure).*color$')); + for field = fields(idx)' + factoryfield = field{1}; + factoryvalue = fac.(factoryfield); + if (strncmp (factoryfield, "factoryfigure", 13)) + ## Strip off "factoryfigure" part of fieldname before applying + set (fig, factoryfield(14:end), factoryvalue); + endif + ## Remove applied default from root + defaultfield = strrep (factoryfield, "factory", "default"); + set (0, defaultfield, "remove"); + endfor endif - endfor - else - ## FIXME: Is this the right thing to do in this case? - set (findall (fig, "type", "axes"), "color", color); - if (isroot) - defs = get (0, "default"); - if (isfield (defs, "defaultaxescolor") - && strcmp (defs.defaultaxescolor, "none")) - set (0, "defaultaxescolor", color); - endif + + hlist = sort (findobj (fig)); + for h = hlist' + props = get (h); + fields = fieldnames (props); + ## Find all fields with the word color in them and restore to factory. + idx = find (! cellfun ("isempty", regexp (fields, 'color$'))); + for field = fields(idx)' + set (h, field{1}, "factory"); + endfor + endfor endif endif endfunction +## Calculate a new color which contrasts with the supplied bg color and is +## perceptually related to the original color. +## +## Input color bg must be in HSV space. Input color corig is in RGB space. +## +## FIXME: Calculation is segregated into its own function in case anyone wants +## to try and improve the selection of a "contrasting" color. +## +## This algorithm maintains at least 90 degrees separation between corig and bg +## in Hue rotation space. No modifications are done for saturation or value. +function cnew = calc_contrast_color (bg, corig) + + hsv = rgb2hsv (corig); + contrast_hue = mod (bg(1) + 0.5, 1); # Generate a contrasting bg color + + ## If close to existing contrast color, leave alone + delta = abs (hsv(1) - contrast_hue); + if (delta < 0.25 || delta > 0.75) + cnew(1) = hsv(1); + else + cnew(1) = mod (hsv(1) + 0.5, 1); + endif + + ## No modifications to saturation or value. + cnew(2:3) = hsv(2:3); + + cnew = hsv2rgb (cnew); + +endfunction + %!test %! dac = get (0, "defaultaxescolor"); %! dfc = get (0, "defaultfigurecolor"); %! hf = figure ("visible", "off"); %! unwind_protect -%! l = line; +%! hl = line ("Color", "r"); %! assert (get (hf, "color"), dfc); %! assert (get (gca, "color"), dac); +%! assert (get (hl, "color"), [1 0 0]); %! whitebg (hf); %! assert (get (hf, "color"), 1 - dfc); %! assert (get (gca, "color"), 1 - dac); +%! assert (get (hl, "color"), [0 1 1]); %! c = [0.2 0.2 0.2]; %! whitebg (hf, c); -%! assert (get (hf, "color"), 1 - dfc); +%! assert (get (hf, "color"), c); %! assert (get (gca, "color"), c); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +## Test input validation +%!error whitebg (1,2,3) +%!error whitebg ({1}, 2) +
--- a/scripts/plot/draw/plotyy.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/draw/plotyy.m Thu Oct 27 22:13:53 2016 -0400 @@ -121,8 +121,8 @@ colors = get (ax(1), "colororder"); set (ax(2), "colororder", [colors(2:end,:); colors(1,:)]); - if (strcmp (get (ax(1), "autopos_tag"), "subplot")) - set (ax(2), "autopos_tag", "subplot"); + if (strcmp (get (ax(1), "__autopos_tag__"), "subplot")) + set (ax(2), "__autopos_tag__", "subplot"); else set (ax, "activepositionproperty", "position"); endif
--- a/scripts/plot/util/gnuplot_binary.in.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/util/gnuplot_binary.in.m Thu Oct 27 22:13:53 2016 -0400 @@ -18,6 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {} {[@var{prog}, @var{args}] =} gnuplot_binary () +## @deftypefnx {} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}) ## @deftypefnx {} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}, @var{arg1}, @dots{}) ## Query or set the name of the program invoked by the plot command when the ## graphics toolkit is set to @qcode{"gnuplot"}. @@ -32,7 +33,7 @@ function [prog, args] = gnuplot_binary (new_prog, varargin) - mlock () + mlock (); persistent gp_binary = %OCTAVE_CONF_GNUPLOT%; persistent gp_args = {}; @@ -41,11 +42,12 @@ args = gp_args; endif - if (nargin == 1) + if (nargin > 0) if (! ischar (new_prog) || isempty (new_prog)) error ("gnuplot_binary: NEW_PROG must be a non-empty string"); endif gp_binary = new_prog; + gp_args = {}; endif if (nargin > 1) @@ -59,10 +61,13 @@ %!test -%! orig_val = gnuplot_binary (); -%! old_val = gnuplot_binary ("__foobar__"); +%! [orig_val, orig_args] = gnuplot_binary (); +%! [old_val, old_args] = gnuplot_binary ("__foobar__", "-opt1"); %! assert (orig_val, old_val); +%! assert (orig_args, old_args); %! assert (gnuplot_binary (), "__foobar__"); -%! gnuplot_binary (orig_val); +%! [~, new_args] = gnuplot_binary (); +%! assert (new_args, {"-opt1"}); +%! gnuplot_binary (orig_val, orig_args{:}); %! assert (gnuplot_binary (), orig_val);
--- a/scripts/plot/util/hdl2struct.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/util/hdl2struct.m Thu Oct 27 22:13:53 2016 -0400 @@ -141,11 +141,10 @@ forbid = {"beingdeleted", "busyaction", "buttondownfcn", ... "children", "clipping", "createfcn", ... "deletefcn", "handlevisibility", "hittest", ... - "interruptible", "parent", "selected" ,... - "selectionhighlight", "type", "__modified__", ... - "uicontextmenu", "__graphics_toolkit__", "currentaxes", ... - "currentcharacter", "currentobject","tightinset", ... - "currentpoint", "extent"}; + "interruptible", "parent", "selected" , ... + "selectionhighlight", "type", "uicontextmenu", ... + "currentaxes", "currentcharacter", "currentobject", ... + "tightinset", "currentpoint", "extent"}; nflds = length (fields); ii = 0; @@ -160,7 +159,7 @@ endwhile ## hidden properties - hidden = {"autopos_tag", "looseinset"}; + hidden = {"__autopos_tag__", "looseinset"}; for ii = 1:numel (hidden) if (isprop (h, hidden{ii})) prpstr.(hidden{ii}) = get (h, hidden{ii});
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Thu Oct 27 22:13:53 2016 -0400 @@ -500,7 +500,10 @@ while (! isempty (kids)) - obj = get (kids(end)); + h_obj = kids(end); + kids = kids(1:(end-1)); + + obj = get (h_obj); if (isfield (obj, "xdata")) obj.xdata = double (obj.xdata); @@ -515,13 +518,12 @@ if (isfield (obj, "units")) units = obj.units; unwind_protect - set (kids(end), "units", "data"); - obj = get (kids(end)); + set (h_obj, "units", "data"); + obj = get (h_obj); unwind_protect_cleanup - set (kids(end), "units", units); + set (h_obj, "units", units); end_unwind_protect endif - kids = kids(1:(end-1)); if (strcmp (obj.visible, "off")) continue; @@ -540,10 +542,6 @@ obj.zdata(obj.zdata<=0) = NaN; endif - if (strcmp (get (obj.parent, "type"), "hggroup")) - obj.displayname = get (obj.parent, "displayname"); - endif - switch (obj.type) case "image" img_data = mapcdata (obj.cdata, obj.cdatamapping, clim, cmap_sz); @@ -614,6 +612,52 @@ withclause{data_idx} = sprintf ("with %s;", imagetype); case "line" + if (strcmp (get (obj.parent, "type"), "hggroup")) + hg = get (obj.parent, "children"); + if (hg(1) == h_obj && ! isempty (get (obj.parent, "displayname"))) + data_idx += 1; + is_image_data(data_idx) = false; + parametric(data_idx) = false; + have_cdata(data_idx) = false; + have_3d_patch(data_idx) = false; + tmpdispname = obj.displayname; + obj.displayname = get (obj.parent, "displayname"); + tmp = undo_string_escapes ( + __maybe_munge_text__ (enhanced, obj, "displayname") + ); + titlespec{data_idx} = ['title "' tmp '"']; + obj.displayname = tmpdispname; + if (! isempty (findobj (obj.parent, "-property", "format", "-depth", 0))) + # Place phantom errorbar data for legend + data{data_idx} = NaN (4,1); + usingclause{data_idx} = sprintf ("record=1 using ($1):($2):($3):($4)"); + switch (get (obj.parent, "format")) + case {"box" "boxy" "boxxy"} + errbars = "boxxy"; + case "xyerr" + errbars = "xyerrorbars"; + case "yerr" + errbars = "yerrorbars"; + case "xerr" + errbars = "xerrorbars"; + otherwise + errbars = "xerrorbars"; + endswitch + withclause{data_idx} = sprintf ("with %s linestyle %d", + errbars, sidx(1)); + else + ## Place phantom stemseries data for legend + data{data_idx} = NaN (2,1); + usingclause{data_idx} = sprintf ("record=1 using ($1):($2)"); + hgobj = get (obj.parent); + [hgstyle, hgsidx] = do_linestyle_command (hgobj, hgobj.color, data_idx, + plot_stream); + withclause{data_idx} = sprintf ("with %s linestyle %d", + hgstyle{1}, hgsidx(1)); + endif + endif + endif + if (strcmp (obj.linestyle, "none") && (! isfield (obj, "marker") || (isfield (obj, "marker") @@ -634,7 +678,6 @@ titlespec{data_idx} = ['title "' tmp '"']; endif usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata)); - errbars = ""; if (nd == 3) xdat = obj.xdata(:); ydat = obj.ydata(:); @@ -657,7 +700,7 @@ endif [style, sidx] = do_linestyle_command (obj, obj.color, data_idx, - plot_stream, errbars); + plot_stream); if isempty (style{1}) style{1} = "points"; @@ -692,6 +735,10 @@ endif case "patch" + if (strcmp (get (obj.parent, "type"), "hggroup")) + obj.displayname = get (obj.parent, "displayname"); + endif + [nr, nc] = size (obj.xdata); if (! isempty (obj.cdata)) @@ -1149,13 +1196,22 @@ case "surface" view_map = true; - if (isempty (obj.displayname)) - tspec = "title \"\""; - else + tspec = 'title ""'; + if (! isempty (obj.displayname)) + ## Place phantom line data for approximate legend symbol + data_idx += 1; + is_image_data(data_idx) = false; + parametric(data_idx) = false; + have_cdata(data_idx) = false; + have_3d_patch(data_idx) = false; tmp = undo_string_escapes ( __maybe_munge_text__ (enhanced, obj, "displayname") ); - tspec = ['title "' tmp '"']; + titlespec{data_idx} = ['title "' tmp '"']; + data{data_idx} = NaN (3,1); + usingclause{data_idx} = sprintf ("record=1 using ($1):($2):($3)"); + withclause{data_idx} = sprintf ("with line linewidth 10 linecolor rgb \"#%02x%02x%02x\"", + round (255*cmap(end/2,:))); endif xdat = obj.xdata; @@ -1850,7 +1906,7 @@ endfunction function [style, ltidx] = do_linestyle_command (obj, linecolor, idx, - plot_stream, errbars = "") + plot_stream) idx = idx + 8; style = {}; ltidx = []; @@ -1882,9 +1938,6 @@ if (! isempty (lt)) fprintf (plot_stream, " %s", lt); endif - if (! isempty (errbars)) - found_style = true; - endif if (isfield (obj, "linewidth")) fprintf (plot_stream, " linewidth %f", obj.linewidth); @@ -1898,111 +1951,100 @@ endif sidx = 1; - if (isempty (errbars)) - if (isempty (lt)) - style{sidx} = ""; - else - style{sidx} = "lines"; - endif - ltidx(sidx) = idx; + if (isempty (lt)) + style{sidx} = ""; + else + style{sidx} = "lines"; + endif + ltidx(sidx) = idx; - facesame = true; - if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") - && ! strcmp (obj.markerfacecolor, "none")) - if (strcmp (obj.markerfacecolor, "auto") - || (isnumeric (obj.markerfacecolor) - && isequal (color, obj.markerfacecolor))) - if (! isempty (pt2)) - fprintf (plot_stream, " pointtype %s", pt2); - style{sidx} = [style{sidx} "points"]; - endif - if (isfield (obj, "markersize")) - fprintf (plot_stream, " pointsize %f", obj.markersize / 3); - endif + facesame = true; + if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") + && ! strcmp (obj.markerfacecolor, "none")) + if (strcmp (obj.markerfacecolor, "auto") + || (isnumeric (obj.markerfacecolor) + && isequal (color, obj.markerfacecolor))) + if (! isempty (pt2)) + fprintf (plot_stream, " pointtype %s", pt2); + style{sidx} = [style{sidx} "points"]; + endif + if (isfield (obj, "markersize")) + fprintf (plot_stream, " pointsize %f", obj.markersize / 3); + endif + else + facesame = false; + if (! found_style) + fputs (plot_stream, " default"); + endif + fputs (plot_stream, ";\n"); + if (! isempty (style{sidx})) + sidx += 1; + idx += 1; else - facesame = false; - if (! found_style) - fputs (plot_stream, " default"); - endif fputs (plot_stream, ";\n"); - if (! isempty (style{sidx})) - sidx += 1; - idx += 1; - else - fputs (plot_stream, ";\n"); - endif - fprintf (plot_stream, "set style line %d default;\n", idx); - fprintf (plot_stream, "set style line %d", idx); - if (isnumeric (obj.markerfacecolor)) - fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", - round (255*obj.markerfacecolor)); - else - fprintf (plot_stream, " palette"); - endif - if (! isempty (pt2)) - style{sidx} = "points"; - ltidx(sidx) = idx; - fprintf (plot_stream, " pointtype %s", pt2); - endif + endif + fprintf (plot_stream, "set style line %d default;\n", idx); + fprintf (plot_stream, "set style line %d", idx); + if (isnumeric (obj.markerfacecolor)) + fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", + round (255*obj.markerfacecolor)); + else + fprintf (plot_stream, " palette"); + endif + if (! isempty (pt2)) + style{sidx} = "points"; + ltidx(sidx) = idx; + fprintf (plot_stream, " pointtype %s", pt2); + endif + if (isfield (obj, "markersize")) + fprintf (plot_stream, " pointsize %f", obj.markersize / 3); + endif + endif + endif + if (! isempty(pt) && isfield (obj, "markeredgecolor") + && ! strcmp (obj.markeredgecolor, "none")) + if (facesame && (strcmp (obj.markeredgecolor, "auto") + || (isnumeric (obj.markeredgecolor) + && isequal (color, obj.markeredgecolor)))) + if (sidx == 1 && ((length (style{sidx}) == 5 + && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx}))) + style{sidx} = [style{sidx} "points"]; + fprintf (plot_stream, " pointtype %s", pt); if (isfield (obj, "markersize")) fprintf (plot_stream, " pointsize %f", obj.markersize / 3); endif endif - endif - if (! isempty(pt) && isfield (obj, "markeredgecolor") - && ! strcmp (obj.markeredgecolor, "none")) - if (facesame && ! isempty (pt) - && (strcmp (obj.markeredgecolor, "auto") - || (isnumeric (obj.markeredgecolor) - && isequal (color, obj.markeredgecolor)))) - if (sidx == 1 && ((length (style{sidx}) == 5 - && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx}))) - if (! isempty (pt)) - style{sidx} = [style{sidx} "points"]; - fprintf (plot_stream, " pointtype %s", pt); - endif - if (isfield (obj, "markersize")) - fprintf (plot_stream, " pointsize %f", obj.markersize / 3); - endif - endif + else + if (! found_style) + fputs (plot_stream, " default"); + endif + fputs (plot_stream, ";\n"); + if (! isempty (style{sidx})) + sidx += 1; + idx += 1; else - if (! found_style) - fputs (plot_stream, " default"); - endif fputs (plot_stream, ";\n"); - if (! isempty (style{sidx})) - sidx += 1; - idx += 1; + endif + fprintf (plot_stream, "set style line %d default;\n", idx); + fprintf (plot_stream, "set style line %d", idx); + if (isnumeric (obj.markeredgecolor) || strcmp (obj.markeredgecolor, "auto")) + if (isnumeric (obj.markeredgecolor)) + edgecolor = obj.markeredgecolor; else - fputs (plot_stream, ";\n"); - endif - fprintf (plot_stream, "set style line %d default;\n", idx); - fprintf (plot_stream, "set style line %d", idx); - if (isnumeric (obj.markeredgecolor) || strcmp (obj.markeredgecolor, "auto")) - if (isnumeric (obj.markeredgecolor)) - edgecolor = obj.markeredgecolor; - else - edgecolor = obj.color; - end - fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", - round (255*edgecolor)); - else - fprintf (plot_stream, " palette"); - endif - if (! isempty (pt)) - style{sidx} = "points"; - ltidx(sidx) = idx; - fprintf (plot_stream, " pointtype %s", pt); - endif - if (isfield (obj, "markersize")) - fprintf (plot_stream, " pointsize %f", obj.markersize / 3); - endif + edgecolor = obj.color; + end + fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", + round (255*edgecolor)); + else + fprintf (plot_stream, " palette"); + endif + style{sidx} = "points"; + ltidx(sidx) = idx; + fprintf (plot_stream, " pointtype %s", pt); + if (isfield (obj, "markersize")) + fprintf (plot_stream, " pointsize %f", obj.markersize / 3); endif endif - else - style{1} = errbars; - ltidx(1) = idx; - fputs (plot_stream, " pointtype 0"); endif if (! found_style && isempty (style{1})) @@ -2106,7 +2148,7 @@ ## FIXME: Should be 6 pt start, using "*" instead pt = pt2 = "3"; case "none" - pt = pt2 = ""; + pt = pt2 = "-1"; otherwise pt = pt2 = ""; endswitch
--- a/scripts/plot/util/struct2hdl.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/plot/util/struct2hdl.m Thu Oct 27 22:13:53 2016 -0400 @@ -181,7 +181,7 @@ if (! any (strcmpi (s.properties.tag, {"colorbar", "legend"}))) ## regular axes propval = {"position", s.properties.position}; - hid = {"autopos_tag", "looseinset"}; + hid = {"__autopos_tag__", "looseinset"}; for ii = 1:numel (hid) prop = hid{ii}; if (isfield (s.properties, prop)) @@ -646,7 +646,7 @@ function addmissingprops (h, props) - hid = {"autopos_tag", "looseinset"}; + hid = {"__autopos_tag__", "looseinset"}; oldfields = fieldnames (props); curfields = fieldnames (get (h)); missing = ! ismember (oldfields, curfields);
--- a/scripts/polynomial/residue.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/polynomial/residue.m Thu Oct 27 22:13:53 2016 -0400 @@ -333,21 +333,10 @@ endfor ## Add the direct term. - if (numel (k)) pnum += conv (pden, k); endif - ## Check for leading zeros and trim the polynomial coefficients. - if (isa (r, "single") || isa (p, "single") || isa (k, "single")) - small = max ([max(abs(pden)), max(abs(pnum)), 1]) * eps ("single"); - else - small = max ([max(abs(pden)), max(abs(pnum)), 1]) * eps; - endif - - pnum(abs (pnum) < small) = 0; - pden(abs (pden) < small) = 0; - pnum = polyreduce (pnum); pden = polyreduce (pden); @@ -383,7 +372,7 @@ %! assert (isempty (k)); %! assert (e, [1; 2; 1; 2]); %! [br, ar] = residue (r, p, k); -%! assert (br, b, 1e-12); +%! assert (br, [0,b], 1e-12); %! assert (ar, a, 1e-12); %!test @@ -431,6 +420,14 @@ %! b = [1, z1]; %! a = [1, -(p1 + p2), p1*p2, 0, 0]; %! [br, ar] = residue (r, p, k, e); -%! assert (br, b, 1e-8); +%! assert (br, [0,0,b], 1e-7); %! assert (ar, a, 1e-8); +%!test <49291> +%! rf = [1e3, 2e3, 1e3, 2e3]; +%! cf = [316.2e-9, 50e-9, 31.6e-9, 5e-9]; +%! [num, den] = residue (1./cf,-1./(rf.*cf),0); +%! assert (numel (num), 4); +%! assert (numel (den), 5); +%! assert (den(1), 1); +
--- a/scripts/startup/__finish__.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/startup/__finish__.m Thu Oct 27 22:13:53 2016 -0400 @@ -27,12 +27,15 @@ ## @seealso{atexit} ## @end deftypefn -## No function declaration, this is an Octave script. This means we are -## still in the base workspace with access to all user variables. +function __finish__ () -if (exist ("finish", "file")) - finish; # No arg list here since finish might be a script. -endif + if (exist ("finish", "file")) + ## Must use evalin for access to base workspace and user variables. + ## No argument list for finish because it might be a script, not function. + evalin ("base", "finish;"); + endif + +endfunction ## No test needed for internal helper m-file.
--- a/scripts/statistics/base/lscov.m Thu Oct 27 22:02:40 2016 -0400 +++ b/scripts/statistics/base/lscov.m Thu Oct 27 22:13:53 2016 -0400 @@ -105,7 +105,7 @@ if (k == 1) S = mse * s; else - S = nan (p, p, k); + S = NaN (p, p, k); for i = 1:k S(:, :, i) = mse(i) * s; endfor
--- a/test/error.tst Thu Oct 27 22:02:40 2016 -0400 +++ b/test/error.tst Thu Oct 27 22:13:53 2016 -0400 @@ -89,25 +89,3 @@ %! w = warning; %! assert (w, w0); -## Test usage() function - -%!function g () -%! usage ("foo"); -%!endfunction -%!function f () -%! g (); -%!endfunction -%!error <foo> f () - -%!function g () -%! usage ("foo"); -%!endfunction -%!function f () -%! g -%!endfunction -%!error <foo> f () - -%!error usage () - -%!error <foo> usage ("foo\n") -