Mercurial > hg > octave-nkf
changeset 14499:f6eb8337d077 gui
periodic merge of default to gui
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 27 Mar 2012 16:15:51 -0400 |
parents | 86847bd1ccf0 (current diff) 36cfbd23fe9f (diff) |
children | f6b4236da9f8 |
files | |
diffstat | 14 files changed, 194 insertions(+), 100 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/install.txi +++ b/doc/interpreter/install.txi @@ -65,16 +65,19 @@ yourself. @menu -* Tips for Specific Systems:: +* Obtaining the Depencies Automatically:: * Build Tools:: * External Packages:: @end menu -@node Tips for Specific Systems -@subsection Tips for Specific Systems +@node Obtaining the Depencies Automatically +@subsection Obtaining the Depencies Automatically -The names of pre-compiled packages vary by system and do not always -match exactly the names listed above. +On some systems you can obtain many of Octave's build dependencies +automatically. The commands for doing this vary by system. Similarly, +the names of pre-compiled packages vary by system and do not always +match exactly the names listed in @ref{Build Tools} and @ref{External +Packages}. You will usually need the development version of an external dependency so that you get the libraries and header files for building software,
--- a/doc/interpreter/octave.texi +++ b/doc/interpreter/octave.texi @@ -890,7 +890,7 @@ Build Dependencies -* Tips for Specific Systems:: +* Obtaining the Depencies Automatically:: * Build Tools:: * External Packages::
--- a/liboctave/mach-info.cc +++ b/liboctave/mach-info.cc @@ -237,19 +237,19 @@ switch (flt_fmt) { case flt_fmt_ieee_big_endian: - retval = "ieee_big_endian"; + retval = "ieee-be"; break; case flt_fmt_ieee_little_endian: - retval = "ieee_little_endian"; + retval = "ieee-le"; break; case flt_fmt_vax_d: - retval = "vax_d_float"; + retval = "vaxd"; break; case flt_fmt_vax_g: - retval = "vax_g_float"; + retval = "vaxg"; break; case flt_fmt_cray:
--- a/scripts/general/interp1.m +++ b/scripts/general/interp1.m @@ -248,9 +248,13 @@ if (ispp) y = shiftdim (reshape (y, szy), 1); yi = pchip (x, y); + yi.orient = "first"; else y = shiftdim (y, 1); yi = pchip (x, y, reshape (xi, szx)); + if (! isvector (y)) + yi = shiftdim (yi, 1); + endif endif case {"spline", "*spline"} if (nx == 2 || starmethod) @@ -260,9 +264,13 @@ if (ispp) y = shiftdim (reshape (y, szy), 1); yi = spline (x, y); + yi.orient = "first"; else y = shiftdim (y, 1); yi = spline (x, y, reshape (xi, szx)); + if (! isvector (y)) + yi = shiftdim (yi, 1); + endif endif otherwise error ("interp1: invalid method '%s'", method); @@ -280,20 +288,11 @@ yi(outliers) = extrap; yi = reshape (yi, szx); elseif (!isvector (yi)) - if (strcmp (method, "pchip") || strcmp (method, "*pchip") - ||strcmp (method, "cubic") || strcmp (method, "*cubic") - ||strcmp (method, "spline") || strcmp (method, "*spline")) - yi(:, outliers) = extrap; - yi = shiftdim(yi, 1); - else - yi(outliers, :) = extrap; - endif + yi(outliers, :) = extrap; else yi(outliers.') = extrap; endif endif - else - yi.orient = "first"; endif endfunction
--- a/scripts/help/gen_doc_cache.m +++ b/scripts/help/gen_doc_cache.m @@ -41,16 +41,23 @@ ## Generate cache if (isempty (directory)) cache = gen_builtin_cache (); + elseif (iscell (directory)) + if all(cellfun (@ischar, directory)) + cache = gen_doc_cache_in_dir (directory); + else + error ("gen_doc_cache: cell must contain only strings"); + end elseif (ischar (directory)) - cache = gen_doc_cache_in_dir (directory); + cache = gen_doc_cache_in_dir (directory); else - error ("gen_doc_cache: second input argument must be a string"); + error ("gen_doc_cache: second input argument must be a string or a cell of strings"); endif ## Save cache if (! isempty (cache)) - save ("-text", out_file, "cache"); + save ("-text", out_file, "cache"); endif + endfunction function [text, first_sentence, status] = handle_function (f, text, format) @@ -108,31 +115,33 @@ endfunction function cache = gen_doc_cache_in_dir (directory) + ## If 'directory' is not in the current path, add it so we search it - dir_in_path = false; - p = path (); - idx = find (p == pathsep ()); - prev_idx = 1; - for n = 1:length (idx) - f = p (prev_idx:idx (n)-1); - if (strcmp (f, directory)) - dir_in_path = true; - break; - endif - prev_idx = idx (n) + 1; - endfor + dir_in_path = ismember (directory, strsplit (path (), pathsep ())); + + # dirs not in path + if !iscell (directory) + directory = {directory}; + end + dirs_notpath = {directory{!dir_in_path}}; + + # add them + if !isempty (dirs_notpath) + cellfun (@addpath, dirs_notpath); + end - if (!dir_in_path) - addpath (directory); - endif + # create cache + func = @(s_) create_cache (__list_functions__ (s_)); + cache = cellfun (func, directory, 'UniformOutput', false); - ## Get list of functions in directory and create cache - list = __list_functions__ (directory); - cache = create_cache (list); + # concatenate results + cache = [cache{:}]; - if (!dir_in_path) - rmpath (directory); - endif + #remove dirs form path + if !isempty (dirs_notpath) + cellfun (@rmpath, dirs_notpath); + end + endfunction function cache = gen_builtin_cache () @@ -148,4 +157,3 @@ %% No true tests desirable for this function. %% Test input validation %!error gen_doc_cache (1) -
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -163,6 +163,12 @@ if (nargin < 1) print_usage (); endif + + if (isempty (str)) + ## Return empty args (no match), rather than raising an error + varargout = cell (1, nargout); + return; + endif if (isempty (format)) format = "%f"; @@ -889,3 +895,10 @@ %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) +%!test +%! # Bug #35999 +%! [a, b, c] = strread ("", "%f"); +%! assert (isempty (a)); +%! assert (isempty (b)); +%! assert (isempty (c)); +
--- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -132,8 +132,8 @@ ## @item mode ## This value determines whether the editor should be started in async mode ## (editor is started in the background and Octave continues) or sync mode -## (Octave waits until the editor exits). Set it to "async" to start the editor -## in async mode. The default is "sync" (see also "system"). +## (Octave waits until the editor exits). Set it to "sync" to start the editor +## in sync mode. The default is "async" (see also "system"). ## ## @item editinplace ## Determines whether files should be edited in place, without regard to
--- a/scripts/pkg/private/create_pkgadddel.m +++ b/scripts/pkg/private/create_pkgadddel.m @@ -29,8 +29,8 @@ ## architecture dependent directory so that the autoload/mfilename ## commands work as expected. The only part that doesn't is the ## part in the main directory. - archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-", - desc.version), getarch ()); + archdir = fullfile (getarchprefix (desc, global_install), cstrcat (desc.name, + "-", desc.version), getarch ()); if (exist (getarchdir (desc, global_install), "dir")) archpkg = fullfile (getarchdir (desc, global_install), nm); archfid = fopen (archpkg, "at");
--- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -1434,10 +1434,10 @@ data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz; endif endfor - fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) * + fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim(1), clim(2) * (cmap_sz + rows(addedcmap)) / cmap_sz); else - fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); + fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim); endif else fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz + @@ -2324,7 +2324,7 @@ n2 = setdiff (n2, n1); end for n = numel(n2):-1:1 - labels{m} = [labels{m}(1:n2(n)-1), "\\", labels{m}(n2(n):end)] + labels{m} = [labels{m}(1:n2(n)-1), "\\", labels{m}(n2(n):end)]; endfor endfor endfor
--- a/scripts/strings/base2dec.m +++ b/scripts/strings/base2dec.m @@ -81,8 +81,27 @@ s = toupper (s); endif - ## Right justify the values before anything else. - s = strjust (s, "right"); + ## Right justify the values and squeeze out any spaces. + ## This looks complicated, but indexing solution is very fast + ## compared to alternatives which use cellstr or cellfun or looping. + [nr, nc] = size (s); + if (nc > 1) # Bug #35621 + s = s.'; + nonbl = s != " "; + num_nonbl = sum (nonbl); + nc = max (num_nonbl); + num_blank = nc - num_nonbl; + R = repmat ([1 2; 0 0], 1, nr); + R(2, 1:2:2*nr) = num_blank; + R(2, 2:2:2*nr) = num_nonbl; + idx = repelems ([false, true], R); + idx = reshape (idx, nc, nr); + + ## Create a blank matrix and position the nonblank characters. + s2 = repmat (" ", nc, nr); + s2(idx) = s(nonbl); + s = s2.'; + endif ## Lookup value of symbols in symbol table, with invalid symbols ## evaluating to NaN and space evaluating to 0.
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -24,7 +24,17 @@ ## @example ## @group ## bin2dec ("1110") -## @result{} 14 +## @result{} 14 +## @end group +## @end example +## +## Spaces are ignored during conversion and may be used to make the binary +## number more readable. +## +## @example +## @group +## bin2dec ("1000 0001") +## @result{} 129 ## @end group ## @end example ## @@ -50,10 +60,12 @@ endfunction -%!assert (bin2dec ("0000"), 0) -%!assert (bin2dec ("1110"), 14) -%!assert (bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) -%!assert (bin2dec ({"1110", "1111"}), [14; 15]) +%!assert(bin2dec ("0000"), 0) +%!assert(bin2dec ("1110"), 14) +%!assert(bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) +%!assert(bin2dec ({"1110", "1111"}), [14; 15]) +%!assert (bin2dec ("1 0 1"), 5) +%!assert (bin2dec (char ("1 0 1", " 1111")), [5; 15]) %%Test input validation %!error bin2dec ()
--- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -442,7 +442,7 @@ DEFUN_DLD (regexp, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}] =} regexp (@var{str}, @var{pat})\n\ +@deftypefn {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexp (@var{str}, @var{pat})\n\ @deftypefnx {Loadable Function} {[@dots{}] =} regexp (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\ Regular expression string matching. Search for @var{pat} in @var{str} and\n\ return the positions and substrings of any matches, or empty values if there\n\ @@ -872,7 +872,7 @@ DEFUN_DLD (regexpi, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}] =} regexpi (@var{str}, @var{pat})\n\ +@deftypefn {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexpi (@var{str}, @var{pat})\n\ @deftypefnx {Loadable Function} {[@dots{}] =} regexpi (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\ \n\ Case insensitive regular expression string matching. Search for @var{pat} in\n\
--- a/src/data.cc +++ b/src/data.cc @@ -1285,7 +1285,7 @@ { octave_idx_type m = args(1).int_value (), n = args(2).int_value (); if (! error_state) - retval = arg0.diag ().resize (dim_vector (m, n)); + retval = arg0.diag ().resize (dim_vector (m, n), true); else error ("diag: invalid dimensions"); } @@ -1299,44 +1299,49 @@ } /* -%!assert (full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3]) -%!assert (diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]) -%!assert (diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]) -%!assert (diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]) -%!assert (diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]) - -%!assert (diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3]) -%!assert (diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3]) -%!assert (diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3]) -%!assert (diag (ones (1, 0), 2), zeros (2)) -%!assert (diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0]) - -%!assert (full (diag (single ([1; 2; 3]))), single ([1, 0, 0; 0, 2, 0; 0, 0, 3])) -%!assert (diag (single ([1; 2; 3]), 1), single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) -%!assert (diag (single ([1; 2; 3]), 2), single ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) -%!assert (diag (single ([1; 2; 3]),-1), single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) -%!assert (diag (single ([1; 2; 3]),-2), single ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) - -%!assert (diag (single ([1, 0, 0; 0, 2, 0; 0, 0, 3])), single ([1; 2; 3])) -%!assert (diag (single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single ([1; 2; 3])) -%!assert (diag (single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single ([1; 2; 3])) - -%!assert (diag (int8 ([1; 2; 3])), int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3])) -%!assert (diag (int8 ([1; 2; 3]), 1), int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) -%!assert (diag (int8 ([1; 2; 3]), 2), int8 ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) -%!assert (diag (int8 ([1; 2; 3]),-1), int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) -%!assert (diag (int8 ([1; 2; 3]),-2), int8 ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) - -%!assert (diag (int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8 ([1; 2; 3])) -%!assert (diag (int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8 ([1; 2; 3])) -%!assert (diag (int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8 ([1; 2; 3])) - -## Test input validation -%!error diag () -%!error diag (1,2,3,4) + +%!assert(full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3]) +%!assert(diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]) +%!assert(diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]) +%!assert(diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]) +%!assert(diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]) + +%!assert(diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3]) +%!assert(diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3]) +%!assert(diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3]) +%!assert(diag (ones(1, 0), 2), zeros (2)) +%!assert(diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0]) + +%!assert(full (diag (single([1; 2; 3]))), single([1, 0, 0; 0, 2, 0; 0, 0, 3])) +%!assert(diag (single([1; 2; 3]), 1), single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) +%!assert(diag (single([1; 2; 3]), 2), single([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) +%!assert(diag (single([1; 2; 3]),-1), single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) +%!assert(diag (single([1; 2; 3]),-2), single([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) + +%!assert(diag (single([1, 0, 0; 0, 2, 0; 0, 0, 3])), single([1; 2; 3])) +%!assert(diag (single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single([1; 2; 3])) +%!assert(diag (single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single([1; 2; 3])) + +%!assert(diag (int8([1; 2; 3])), int8([1, 0, 0; 0, 2, 0; 0, 0, 3])) +%!assert(diag (int8([1; 2; 3]), 1), int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) +%!assert(diag (int8([1; 2; 3]), 2), int8([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) +%!assert(diag (int8([1; 2; 3]),-1), int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) +%!assert(diag (int8([1; 2; 3]),-2), int8([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) + +%!assert(diag (int8([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8([1; 2; 3])) +%!assert(diag (int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8([1; 2; 3])) +%!assert(diag (int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8([1; 2; 3])) + +## Test non-square size +%!assert(diag ([1,2,3], 6, 3), [1 0 0; 0 2 0; 0 0 3; 0 0 0; 0 0 0; 0 0 0]) + +%% Test input validation +%!error <Invalid call to diag> diag () +%!error <Invalid call to diag> diag (1,2,3,4) %!error diag (ones (2), 3, 3) %!error diag (1:3, -4, 3) -*/ + + */ DEFUN (prod, args, , "-*- texinfo -*-\n\
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -3585,8 +3585,8 @@ } else if (punits == "points") { - sz(0) = 72.0; - sz(1) = 72.0; + sz(0) /= 72.0; + sz(1) /= 72.0; } if (punits == "normalized") { @@ -3656,6 +3656,16 @@ // update_papersize and update_papertype papertype.set (typ); } + if (punits == "centimeters") + { + sz(0) *= 2.54; + sz(1) *= 2.54; + } + else if (punits == "points") + { + sz(0) *= 72.0; + sz(1) *= 72.0; + } if (get_paperorientation () == "landscape") { std::swap (sz(0), sz(1)); @@ -3663,6 +3673,31 @@ } } +/* +%!test +%! figure (1, "visible", "off"); +%! set (1, "paperunits", "inches"); +%! set (1, "papersize", [5, 4]) +%! set (1, "paperunits", "points"); +%! assert (get (1, "papersize"), [5, 4] * 72, 1) +%! papersize = get (gcf, "papersize"); +%! set (1, "papersize", papersize + 1); +%! set (1, "papersize", papersize) +%! assert (get (1, "papersize"), [5, 4] * 72, 1) +%! close (1) +%!test +%! figure (1, "visible", "off"); +%! set (1, "paperunits", "inches"); +%! set (1, "papersize", [5, 4]) +%! set (1, "paperunits", "centimeters"); +%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72) +%! papersize = get (gcf, "papersize"); +%! set (1, "papersize", papersize + 1); +%! set (1, "papersize", papersize) +%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72) +%! close (1) +*/ + void figure::properties::update_paperorientation (void) {