# HG changeset patch # User John W. Eaton # Date 1432978787 14400 # Node ID 3e8c188b20a794d574e903a5f48957af96611b2a # Parent e8da1c10194f8fd91d18a7a3975be12310484bd8# Parent 3ccc2d02e64b61c6827009d42e5b12274e7ba5fc maint: Periodic merge of stable to default. diff -r 3ccc2d02e64b -r 3e8c188b20a7 .hgtags --- a/.hgtags Sat May 23 10:35:40 2015 -0400 +++ b/.hgtags Sat May 30 05:39:47 2015 -0400 @@ -94,3 +94,4 @@ eba80000fa0dad32ba0f1cd767dd826d1ce1aba6 rc-4-0-0-2 065f933ef08318e40b81f7fe75236e6175088117 rc-4-0-0-3 42bb3a776c9fcc008669f382d2409297c4a901b3 rc-4-0-0-4 +3ccc2d02e64b61c6827009d42e5b12274e7ba5fc release-4-0-0 diff -r 3ccc2d02e64b -r 3e8c188b20a7 NEWS --- a/NEWS Sat May 23 10:35:40 2015 -0400 +++ b/NEWS Sat May 30 05:39:47 2015 -0400 @@ -1,3 +1,32 @@ +Summary of important user-visible changes for version 4.2: +--------------------------------------------------------- + + ** Octal ('\NNN') and hex ('\xNN') escape sequences in single quoted + strings are now interpreted by the function do_string_escapes(). + The *printf family of functions now supports octal and hex escape + sequences in single-quoted strings for Matlab compatibility. + + ** Special octal and hex escape sequences for the pattern and replacement + strings in regular expressions are now interpreted for Matlab compatibility. + + octal: '\oNNN' or '\o{NNN}' + hex : '\xNN' or '\x{NN}' + + ** mkfifo now interprets the MODE argument as an octal, not decimal, integer. + This is consistent with the equivalent shell command. + + ** The griddata function no longer plots the interpolated mesh if no output + argument is requested, instead the vector or array of interpolated values + is always returned for Matlab compatibility. + + ** The surfnorm function now returns unnormalized (magnitude != 1) normal + vectors for compatibility with Matlab. + + ** Other new functions added in 4.2: + + psi + + Summary of important user-visible changes for version 4.0: --------------------------------------------------------- diff -r 3ccc2d02e64b -r 3e8c188b20a7 build-aux/common.mk --- a/build-aux/common.mk Sat May 23 10:35:40 2015 -0400 +++ b/build-aux/common.mk Sat May 30 05:39:47 2015 -0400 @@ -537,7 +537,6 @@ -e "s|%OCTAVE_CONF_CXXCPP%|\"${CXXCPP}\"|" \ -e "s|%OCTAVE_CONF_CXXFLAGS%|\"${CXXFLAGS}\"|" \ -e "s|%OCTAVE_CONF_CXXPICFLAG%|\"${CXXPICFLAG}\"|" \ - -e "s|%OCTAVE_CONF_CXX_VERSION%|\"${CXX_VERSION}\"|" \ -e "s|%OCTAVE_CONF_DEFAULT_PAGER%|\"${DEFAULT_PAGER}\"|" \ -e "s|%OCTAVE_CONF_DEFS%|\"${DEFS}\"|" \ -e "s|%OCTAVE_CONF_DEPEND_FLAGS%|\"${DEPEND_FLAGS}\"|" \ @@ -707,7 +706,6 @@ -e "s|%OCTAVE_CONF_CXXCPP%|\"${CXXCPP}\"|" \ -e "s|%OCTAVE_CONF_CXXFLAGS%|\"${CXXFLAGS}\"|" \ -e "s|%OCTAVE_CONF_CXXPICFLAG%|\"${CXXPICFLAG}\"|" \ - -e "s|%OCTAVE_CONF_CXX_VERSION%|\"${CXX_VERSION}\"|" \ -e "s|%OCTAVE_CONF_DEFAULT_PAGER%|\"${DEFAULT_PAGER}\"|" \ -e "s|%OCTAVE_CONF_DEFS%|\"${DEFS}\"|" \ -e "s|%OCTAVE_CONF_DEPEND_FLAGS%|\"${DEPEND_FLAGS}\"|" \ diff -r 3ccc2d02e64b -r 3e8c188b20a7 build-aux/mk-opts.pl --- a/build-aux/mk-opts.pl Sat May 23 10:35:40 2015 -0400 +++ b/build-aux/mk-opts.pl Sat May 30 05:39:47 2015 -0400 @@ -676,14 +676,14 @@ $elt_type = "octave_idx_type"; } print qq| Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; - print qq| if (val.length () == 1) + print qq| if (val.numel () == 1) { os << val(0) << "\\n"; } else { os << "\\n\\n"; - octave_idx_type len = val.length (); + octave_idx_type len = val.numel (); Matrix tmp (len, 1); for (octave_idx_type i = 0; i < len; i++) tmp(i,0) = val(i); @@ -694,7 +694,7 @@ elsif ($TYPE[$i] eq "Array") { print qq| Array val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; - print qq| if (val.length () == 1) + print qq| if (val.numel () == 1) { os << val(0) << "\\n"; } @@ -709,7 +709,7 @@ elsif ($TYPE[$i] eq "Array") { print qq| Array val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; - print qq| if (val.length () == 1) + print qq| if (val.numel () == 1) { os << val(0) << "\\n"; } @@ -856,13 +856,13 @@ $elt_type = "octave_idx_type"; } print " Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; - print " if (val.length () == 1) + print " if (val.numel () == 1) { retval = static_cast (val(0)); } else { - octave_idx_type len = val.length (); + octave_idx_type len = val.numel (); ColumnVector tmp (len); for (octave_idx_type i = 0; i < len; i++) tmp(i) = val(i); @@ -872,7 +872,7 @@ elsif ($TYPE[$i] eq "Array") { print " Array val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; - print " if (val.length () == 1) + print " if (val.numel () == 1) { retval = val(0); } @@ -884,7 +884,7 @@ elsif ($TYPE[$i] eq "Array") { print " Array val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; - print " if (val.length () == 1) + print " if (val.numel () == 1) { retval = val(0); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 configure.ac --- a/configure.ac Sat May 23 10:35:40 2015 -0400 +++ b/configure.ac Sat May 30 05:39:47 2015 -0400 @@ -19,14 +19,14 @@ ### . AC_PREREQ([2.63]) -AC_INIT([GNU Octave], [4.0.0], [http://octave.org/bugs.html], [octave]) +AC_INIT([GNU Octave], [4.1.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=0 -OCTAVE_PATCH_VERSION=0 +OCTAVE_MINOR_VERSION=1 +OCTAVE_PATCH_VERSION=0+ dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION" diff -r 3ccc2d02e64b -r 3e8c188b20a7 doc/interpreter/arith.txi --- a/doc/interpreter/arith.txi Sat May 23 10:35:40 2015 -0400 +++ b/doc/interpreter/arith.txi Sat May 30 05:39:47 2015 -0400 @@ -315,6 +315,8 @@ @anchor{XREFgammaln} @DOCSTRING(lgamma) +@DOCSTRING(psi) + @node Rational Approximations @section Rational Approximations diff -r 3ccc2d02e64b -r 3e8c188b20a7 doc/interpreter/geometry.txi --- a/doc/interpreter/geometry.txi Sat May 23 10:35:40 2015 -0400 +++ b/doc/interpreter/geometry.txi Sat May 30 05:39:47 2015 -0400 @@ -433,7 +433,8 @@ y = 2*rand (size (x)) - 1; z = sin (2*(x.^2+y.^2)); [xx,yy] = meshgrid (linspace (-1,1,32)); -griddata (x,y,z,xx,yy); +zz = griddata (x, y, z, xx, yy); +mesh (xx, yy, zz); @end group @end example diff -r 3ccc2d02e64b -r 3e8c188b20a7 doc/interpreter/geometryimages.m --- a/doc/interpreter/geometryimages.m Sat May 23 10:35:40 2015 -0400 +++ b/doc/interpreter/geometryimages.m Sat May 30 05:39:47 2015 -0400 @@ -65,7 +65,8 @@ y = 2 * rand (size (x)) - 1; z = sin (2 * (x.^2 + y.^2)); [xx,yy] = meshgrid (linspace (-1,1,32)); - griddata (x,y,z,xx,yy); + zz = griddata (x, y, z, xx, yy); + mesh (xx, yy, zz); print ([nm "." typ], d_typ); elseif (strcmp (nm, "convhull")) x = -3:0.05:3; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libgui/graphics/QtHandlesUtils.cc --- a/libgui/graphics/QtHandlesUtils.cc Sat May 23 10:35:40 2015 -0400 +++ b/libgui/graphics/QtHandlesUtils.cc Sat May 30 05:39:47 2015 -0400 @@ -61,7 +61,7 @@ fromStringVector (const string_vector& v) { QStringList l; - octave_idx_type n = v.length (); + octave_idx_type n = v.numel (); for (octave_idx_type i = 0; i < n; i++) l << fromStdString (v[i]); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libgui/src/dialog.cc --- a/libgui/src/dialog.cc Sat May 23 10:35:40 2015 -0400 +++ b/libgui/src/dialog.cc Sat May 30 05:39:47 2015 -0400 @@ -519,7 +519,7 @@ // if not showing only dirs, add end slash for the path component if (testOption (QFileDialog::ShowDirsOnly) == false) - path = path + "/"; + path += "/"; // convert to native slashes path = QDir::toNativeSeparators (path); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Sat May 23 10:35:40 2015 -0400 +++ b/libgui/src/m-editor/file-editor-tab.cc Sat May 30 05:39:47 2015 -0400 @@ -482,12 +482,12 @@ _prep_apis_file = prep_apis_path + lexer->lexer () + "_k"; if (octave_builtins) - _prep_apis_file = _prep_apis_file + "b"; // use builtins, too + _prep_apis_file += "b"; // use builtins, too if (octave_functions) - _prep_apis_file = _prep_apis_file + "f"; // use keywords, too + _prep_apis_file += "f"; // use keywords, too - _prep_apis_file = _prep_apis_file + ".pap"; // final name of apis file + _prep_apis_file += ".pap"; // final name of apis file // check whether the APIs info needs to be prepared and saved QFileInfo apis_file = QFileInfo (_prep_apis_file); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat May 23 10:35:40 2015 -0400 +++ b/libgui/src/main-window.cc Sat May 30 05:39:47 2015 -0400 @@ -747,7 +747,7 @@ { // if children has a name icon = widget_icon_data[icon_set_found].path; // prefix or octave-logo if (widget_icon_data[icon_set_found].name != "NONE") - icon = icon + name + ".png"; // add widget name and ext. + icon += name + ".png"; // add widget name and ext. widget->setWindowIcon (QIcon (icon)); } } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libgui/src/octave-qt-link.cc --- a/libgui/src/octave-qt-link.cc Sat May 23 10:35:40 2015 -0400 +++ b/libgui/src/octave-qt-link.cc Sat May 30 05:39:47 2015 -0400 @@ -490,7 +490,7 @@ { QStringList qt_hist; - for (octave_idx_type i = 0; i < hist.length (); i++) + for (octave_idx_type i = 0; i < hist.numel (); i++) qt_hist.append (QString::fromStdString (hist[i])); emit set_history_signal (qt_hist); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/Cell.cc --- a/libinterp/corefcn/Cell.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/Cell.cc Sat May 30 05:39:47 2015 -0400 @@ -40,7 +40,7 @@ Cell::Cell (const string_vector& sv, bool trim) : Array () { - octave_idx_type n = sv.length (); + octave_idx_type n = sv.numel (); if (n > 0) { @@ -99,7 +99,7 @@ Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim) : Array (dv, Matrix ()) { - octave_idx_type n = sv.length (); + octave_idx_type n = sv.numel (); if (n > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/__contourc__.cc --- a/libinterp/corefcn/__contourc__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/__contourc__.cc Sat May 30 05:39:47 2015 -0400 @@ -316,7 +316,7 @@ { contourc.resize (2, 0); - for (int i = 0; i < L.length (); i++) + for (int i = 0; i < L.numel (); i++) cntr (X, Y, Z, L (i)); end_contour (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/__pchip_deriv__.cc --- a/libinterp/corefcn/__pchip_deriv__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/__pchip_deriv__.cc Sat May 30 05:39:47 2015 -0400 @@ -68,7 +68,7 @@ FloatColumnVector xvec (args(0).float_vector_value ()); FloatMatrix ymat (args(1).float_matrix_value ()); - octave_idx_type nx = xvec.length (); + octave_idx_type nx = xvec.numel (); if (nx < 2) { @@ -115,7 +115,7 @@ ColumnVector xvec (args(0).vector_value ()); Matrix ymat (args(1).matrix_value ()); - octave_idx_type nx = xvec.length (); + octave_idx_type nx = xvec.numel (); if (nx < 2) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/__qp__.cc --- a/libinterp/corefcn/__qp__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/__qp__.cc Sat May 30 05:39:47 2015 -0400 @@ -62,7 +62,7 @@ double tol = tmp * s(0) * std::numeric_limits::epsilon (); - octave_idx_type n = s.length (); + octave_idx_type n = s.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -97,11 +97,11 @@ double rtol = sqrt (std::numeric_limits::epsilon ()); // Problem dimension. - octave_idx_type n = x.length (); + octave_idx_type n = x.numel (); // Dimension of constraints. - octave_idx_type n_eq = beq.length (); - octave_idx_type n_in = bin.length (); + octave_idx_type n_eq = beq.numel (); + octave_idx_type n_in = bin.numel (); // Filling the current active set. diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/besselj.cc --- a/libinterp/corefcn/besselj.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/besselj.cc Sat May 30 05:39:47 2015 -0400 @@ -178,8 +178,8 @@ dim_vector dv0 = args(0).dims (); dim_vector dv1 = args(1).dims (); - bool args0_is_row_vector = (dv0 (1) == dv0.numel ()); - bool args1_is_col_vector = (dv1 (0) == dv1.numel ()); + bool args0_is_row_vector = (dv0(1) == dv0.numel ()); + bool args1_is_col_vector = (dv1(0) == dv1.numel ()); if (args0_is_row_vector && args1_is_col_vector) { @@ -314,8 +314,8 @@ dim_vector dv0 = args(0).dims (); dim_vector dv1 = args(1).dims (); - bool args0_is_row_vector = (dv0 (1) == dv0.numel ()); - bool args1_is_col_vector = (dv1 (0) == dv1.numel ()); + bool args0_is_row_vector = (dv0(1) == dv0.numel ()); + bool args1_is_col_vector = (dv1(0) == dv1.numel ()); if (args0_is_row_vector && args1_is_col_vector) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/bsxfun.cc --- a/libinterp/corefcn/bsxfun.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/bsxfun.cc Sat May 30 05:39:47 2015 -0400 @@ -237,12 +237,12 @@ idx(0) = octave_value (':'); for (octave_idx_type j = 1; j < nd; j++) { - if (dva (j) == 1) + if (dva(j) == 1) idx(j) = octave_value (1); else idx(j) = octave_value ((i % dvc(j)) + 1); - i = i / dvc (j); + i /= dvc(j); } Ac = A; @@ -256,14 +256,14 @@ octave_idx_type k1 = i - 1; for (octave_idx_type j = 1; j < nd; j++) { - if (dva(j) != 1 && k % dvc (j) != k1 % dvc (j)) + if (dva(j) != 1 && k % dvc(j) != k1 % dvc(j)) { idx (j) = octave_value ((k % dvc(j)) + 1); is_changed = true; } - k = k / dvc (j); - k1 = k1 / dvc (j); + k /= dvc(j); + k1 /= dvc(j); } if (is_changed) @@ -294,8 +294,8 @@ { for (octave_idx_type j = 1; j < nd; j++) { - idx (j) = octave_value (i % dv (j) + 1); - i = i / dv (j); + idx (j) = octave_value (i % dv(j) + 1); + i /= dv(j); } } } @@ -309,8 +309,8 @@ idx(0) = 0; for (octave_idx_type j = 1; j < nd; j++) { - idx (j) = i % dv (j); - i = i / dv (j); + idx(j) = i % dv(j); + i /= dv(j); } } @@ -391,7 +391,7 @@ } for (octave_idx_type i = 0; i < nd; i++) - if (dva (i) != dvb (i) && dva (i) != 1 && dvb (i) != 1) + if (dva(i) != dvb(i) && dva(i) != 1 && dvb(i) != 1) { error ("bsxfun: dimensions of A and B must match"); break; @@ -404,10 +404,10 @@ dvc.resize (nd); for (octave_idx_type i = 0; i < nd; i++) - dvc (i) = (dva (i) < 1 ? dva (i) - : (dvb (i) < 1 ? dvb (i) - : (dva (i) > dvb (i) - ? dva (i) : dvb (i)))); + dvc(i) = (dva(i) < 1 ? dva(i) + : (dvb(i) < 1 ? dvb(i) + : (dva(i) > dvb(i) + ? dva(i) : dvb(i)))); if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1) { @@ -427,7 +427,7 @@ { octave_idx_type ncount = 1; for (octave_idx_type i = 1; i < nd; i++) - ncount *= dvc (i); + ncount *= dvc(i); #define BSXDEF(T) \ T result_ ## T; \ diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/cellfun.cc Sat May 30 05:39:47 2015 -0400 @@ -1714,7 +1714,7 @@ dim_vector& celldv, dim_vector& arraydv, Array& perm) { - int dvl = dimv.length (); + int dvl = dimv.numel (); int maxd = dv.length (); celldv = dv; for (int i = 0; i < dvl; i++) @@ -1981,7 +1981,7 @@ for (int i = 0; i < nd; i++) { octave_idx_type s = 0; - for (octave_idx_type j = 0; j < d[i].length (); j++) + for (octave_idx_type j = 0; j < d[i].numel (); j++) s += d[i](j); octave_idx_type r = i < dv.length () ? dv(i) : 1; @@ -2031,8 +2031,8 @@ if (mat2cell_mismatch (a.dims (), d, nd)) return retval; - octave_idx_type nridx = d[0].length (); - octave_idx_type ncidx = nd == 1 ? 1 : d[1].length (); + octave_idx_type nridx = d[0].numel (); + octave_idx_type ncidx = nd == 1 ? 1 : d[1].numel (); retval.clear (nridx, ncidx); int ivec = -1; @@ -2092,7 +2092,7 @@ octave_idx_type idxtot = 0; for (int i = 0; i < nd; i++) { - rdv(i) = nidx[i] = d[i].length (); + rdv(i) = nidx[i] = d[i].numel (); idxtot += nidx[i]; } @@ -2156,7 +2156,7 @@ octave_idx_type idxtot = 0; for (int i = 0; i < nd; i++) { - rdv(i) = nidx[i] = d[i].length (); + rdv(i) = nidx[i] = d[i].numel (); idxtot += nidx[i]; } @@ -2339,7 +2339,7 @@ const Array& ub, int dim = -1) { - octave_idx_type n = lb.length (); + octave_idx_type n = lb.numel (); Cell retval (1, n); if (array.is_vector () && (dim == -1 || (dim == 0 && array.columns () == 1) @@ -2409,7 +2409,7 @@ if (! error_state) { - if (lb.length () != ub.length ()) + if (lb.numel () != ub.numel ()) error ("cellslices: the lengths of LB and UB must match"); else { @@ -2472,7 +2472,7 @@ else { // generic code. - octave_idx_type n = lb.length (); + octave_idx_type n = lb.numel (); retcell = Cell (1, n); const dim_vector dv = x.dims (); int ndims = dv.length (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/daspk.cc --- a/libinterp/corefcn/daspk.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/daspk.cc Sat May 30 05:39:47 2015 -0400 @@ -63,7 +63,7 @@ { ColumnVector retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -95,7 +95,7 @@ if (tlen > 1) ires = tmp(1).int_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("daspk"); } else @@ -111,7 +111,7 @@ { Matrix retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -141,7 +141,7 @@ retval = tmp(0).matrix_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("daspk"); } else @@ -297,9 +297,9 @@ if (f_arg.is_cell ()) { Cell c = f_arg.cell_value (); - if (c.length () == 1) + if (c.numel () == 1) f_arg = c(0); - else if (c.length () == 2) + else if (c.numel () == 2) { if (c(0).is_function_handle () || c(0).is_inline_function ()) daspk_fcn = c(0).function_value (); @@ -426,7 +426,7 @@ crit_times_set = 1; } - if (state.capacity () != deriv.capacity ()) + if (state.numel () != deriv.numel ()) DASPK_ABORT1 ("x and xdot must have the same size"); double tzero = out_times (0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/dasrt.cc --- a/libinterp/corefcn/dasrt.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/dasrt.cc Sat May 30 05:39:47 2015 -0400 @@ -63,7 +63,7 @@ { ColumnVector retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -91,7 +91,7 @@ retval = ColumnVector (tmp(0).vector_value ()); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("dasrt"); } else @@ -131,7 +131,7 @@ retval = ColumnVector (tmp(0).vector_value ()); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("dasrt"); } else @@ -147,7 +147,7 @@ { Matrix retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -177,7 +177,7 @@ retval = tmp(0).matrix_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("dasrt"); } else @@ -385,9 +385,9 @@ if (f_arg.is_cell ()) { Cell c = f_arg.cell_value (); - if (c.length () == 1) + if (c.numel () == 1) f_arg = c(0); - else if (c.length () == 2) + else if (c.numel () == 2) { if (c(0).is_function_handle () || c(0).is_inline_function ()) dasrt_f = c(0).function_value (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/dassl.cc --- a/libinterp/corefcn/dassl.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/dassl.cc Sat May 30 05:39:47 2015 -0400 @@ -63,7 +63,7 @@ { ColumnVector retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -95,7 +95,7 @@ if (tlen > 1) ires = tmp(1).int_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("dassl"); } else @@ -111,7 +111,7 @@ { Matrix retval; - assert (x.capacity () == xdot.capacity ()); + assert (x.numel () == xdot.numel ()); octave_value_list args; @@ -141,7 +141,7 @@ retval = tmp(0).matrix_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("dassl"); } else @@ -298,9 +298,9 @@ if (f_arg.is_cell ()) { Cell c = f_arg.cell_value (); - if (c.length () == 1) + if (c.numel () == 1) f_arg = c(0); - else if (c.length () == 2) + else if (c.numel () == 2) { if (c(0).is_function_handle () || c(0).is_inline_function ()) dassl_fcn = c(0).function_value (); @@ -427,7 +427,7 @@ crit_times_set = 1; } - if (state.capacity () != deriv.capacity ()) + if (state.numel () != deriv.numel ()) DASSL_ABORT1 ("x and xdot must have the same size"); double tzero = out_times (0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/data.cc Sat May 30 05:39:47 2015 -0400 @@ -2051,7 +2051,7 @@ retval = do_single_type_concat_map (args, dim); else { - dim_vector dv = args(0).dims (); + dim_vector dv = args(0).dims (); // Default concatenation. bool (dim_vector::*concat_rule) (const dim_vector&, int) @@ -2115,8 +2115,7 @@ break; } else - ra_idx (dim) += (dim < dv_tmp.length () ? - dv_tmp (dim) : 1); + ra_idx(dim) += (dim < dv_tmp.length () ? dv_tmp(dim) : 1); } retval = tmp; } @@ -2584,7 +2583,7 @@ // FIXME: maybe we should create an idx_vector object // here and pass that to permute? - int n = vec.length (); + int n = vec.numel (); for (int i = 0; i < n; i++) vec(i)--; @@ -4065,8 +4064,8 @@ case oct_data_conv::dt_double: { - if (val == 1 && dims.length () == 2 && dims (0) == 1) - retval = Range (1.0, 0.0, dims (1)); // packed form + if (val == 1 && dims.length () == 2 && dims(0) == 1) + retval = Range (1.0, 0.0, dims(1)); // packed form else retval = NDArray (dims, val); } @@ -5263,7 +5262,7 @@ else { CVT lv = octave_value_extract (limit); - CVT bv (lv.length (), bs); + CVT bv (lv.numel (), bs); retval = linspace (bv, lv, n); } } @@ -5273,7 +5272,7 @@ if (limit.is_scalar_type ()) { T ls = octave_value_extract (limit); - CVT lv (bv.length (), ls); + CVT lv (bv.numel (), ls); retval = linspace (bv, lv, n); } else @@ -5433,7 +5432,7 @@ if (nargin == 2) { Array vec = args(1).vector_value (); - int ndim = vec.length (); + int ndim = vec.numel (); if (ndim == 1) { octave_idx_type m = static_cast (vec(0)); @@ -5514,15 +5513,15 @@ { Array new_size = args(1).octave_idx_type_vector_value (); - if (new_size.length () < 2) + if (new_size.numel () < 2) { error ("reshape: SIZE must have 2 or more dimensions"); return retval; } - new_dims = dim_vector::alloc (new_size.length ()); - - for (octave_idx_type i = 0; i < new_size.length (); i++) + new_dims = dim_vector::alloc (new_size.numel ()); + + for (octave_idx_type i = 0; i < new_size.numel (); i++) { if (new_size(i) < 0) { @@ -8127,8 +8126,8 @@ if (! error_state) { - dims = dim_vector::alloc (size.length ()); - for (octave_idx_type i = 0; i < size.length (); i++) + dims = dim_vector::alloc (size.numel ()); + for (octave_idx_type i = 0; i < size.numel (); i++) dims(i) = size(i); } } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/debug.cc Sat May 30 05:39:47 2015 -0400 @@ -263,7 +263,7 @@ if (error_state) break; - for (octave_idx_type j = 0; j < arg.nelem (); j++) + for (octave_idx_type j = 0; j < arg.numel (); j++) { int line = static_cast (arg.elem (j)); if (error_state) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/dot.cc --- a/libinterp/corefcn/dot.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/dot.cc Sat May 30 05:39:47 2015 -0400 @@ -173,7 +173,7 @@ FloatComplexNDArray x = argx.float_complex_array_value (); FloatComplexNDArray y = argy.float_complex_array_value (); get_red_dims (dimx, dimy, dim, dimz, m, n, k); - FloatComplexNDArray z(dimz); + FloatComplexNDArray z (dimz); if (! error_state) F77_XFCN (cdotc3, CDOTC3, (m, n, k, x.data (), y.data (), @@ -185,7 +185,7 @@ ComplexNDArray x = argx.complex_array_value (); ComplexNDArray y = argy.complex_array_value (); get_red_dims (dimx, dimy, dim, dimz, m, n, k); - ComplexNDArray z(dimz); + ComplexNDArray z (dimz); if (! error_state) F77_XFCN (zdotc3, ZDOTC3, (m, n, k, x.data (), y.data (), @@ -200,7 +200,7 @@ FloatNDArray x = argx.float_array_value (); FloatNDArray y = argy.float_array_value (); get_red_dims (dimx, dimy, dim, dimz, m, n, k); - FloatNDArray z(dimz); + FloatNDArray z (dimz); if (! error_state) F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (), z.fortran_vec ())); @@ -211,7 +211,7 @@ NDArray x = argx.array_value (); NDArray y = argy.array_value (); get_red_dims (dimx, dimy, dim, dimz, m, n, k); - NDArray z(dimz); + NDArray z (dimz); if (! error_state) F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (), z.fortran_vec ())); @@ -340,7 +340,7 @@ { FloatComplexNDArray x = argx.float_complex_array_value (); FloatComplexNDArray y = argy.float_complex_array_value (); - FloatComplexNDArray z(dimz); + FloatComplexNDArray z (dimz); if (! error_state) F77_XFCN (cmatm3, CMATM3, (m, n, k, np, x.data (), y.data (), @@ -351,7 +351,7 @@ { ComplexNDArray x = argx.complex_array_value (); ComplexNDArray y = argy.complex_array_value (); - ComplexNDArray z(dimz); + ComplexNDArray z (dimz); if (! error_state) F77_XFCN (zmatm3, ZMATM3, (m, n, k, np, x.data (), y.data (), @@ -365,7 +365,7 @@ { FloatNDArray x = argx.float_array_value (); FloatNDArray y = argy.float_array_value (); - FloatNDArray z(dimz); + FloatNDArray z (dimz); if (! error_state) F77_XFCN (smatm3, SMATM3, (m, n, k, np, x.data (), y.data (), @@ -376,7 +376,7 @@ { NDArray x = argx.array_value (); NDArray y = argy.array_value (); - NDArray z(dimz); + NDArray z (dimz); if (! error_state) F77_XFCN (dmatm3, DMATM3, (m, n, k, np, x.data (), y.data (), diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/fft.cc --- a/libinterp/corefcn/fft.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/fft.cc Sat May 30 05:39:47 2015 -0400 @@ -112,9 +112,9 @@ } if (n_points < 0) - n_points = dims (dim); + n_points = dims(dim); else - dims (dim) = n_points; + dims(dim) = n_points; if (dims.any_zero () || n_points == 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/fft2.cc --- a/libinterp/corefcn/fft2.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/fft2.cc Sat May 30 05:39:47 2015 -0400 @@ -96,14 +96,14 @@ return retval; if (n_rows < 0) - n_rows = dims (0); + n_rows = dims(0); else - dims (0) = n_rows; + dims(0) = n_rows; if (n_cols < 0) - n_cols = dims (1); + n_cols = dims(1); else - dims (1) = n_cols; + dims(1) = n_cols; if (dims.all_zero () || n_rows == 0 || n_cols == 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/file-io.cc --- a/libinterp/corefcn/file-io.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/file-io.cc Sat May 30 05:39:47 2015 -0400 @@ -2204,6 +2204,8 @@ return retval; } +// FIXME: This routine also exists verbatim in syscalls.cc. +// Maybe change to be a general utility routine. static int convert (int x, int ibase, int obase) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/filter.cc --- a/libinterp/corefcn/filter.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/filter.cc Sat May 30 05:39:47 2015 -0400 @@ -60,8 +60,8 @@ { MArray y; - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type ab_len = a_len > b_len ? a_len : b_len; @@ -127,8 +127,8 @@ if (norm != static_cast (1.0)) { - a = a / norm; - b = b / norm; + a /= norm; + b /= norm; } if (a_len <= 1 && si_len <= 0) @@ -275,8 +275,8 @@ return MArray (); } - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; dim_vector si_dims = x.dims (); @@ -451,8 +451,8 @@ if (nargin == 3 || args(3).is_empty ()) { - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; @@ -499,8 +499,8 @@ if (nargin == 3 || args(3).is_empty ()) { - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; @@ -550,8 +550,8 @@ if (nargin == 3 || args(3).is_empty ()) { - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; @@ -598,8 +598,8 @@ if (nargin == 3 || args(3).is_empty ()) { - octave_idx_type a_len = a.length (); - octave_idx_type b_len = b.length (); + octave_idx_type a_len = a.numel (); + octave_idx_type b_len = b.numel (); octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/find.cc --- a/libinterp/corefcn/find.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/find.cc Sat May 30 05:39:47 2015 -0400 @@ -61,7 +61,7 @@ case 2: { Array jdx (idx.dims ()); - octave_idx_type n = idx.length (); + octave_idx_type n = idx.numel (); octave_idx_type nr = nda.rows (); for (octave_idx_type i = 0; i < n; i++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/gl-render.cc --- a/libinterp/corefcn/gl-render.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/gl-render.cc Sat May 30 05:39:47 2015 -0400 @@ -667,7 +667,7 @@ // Clear background - if (c.length () >= 3) + if (c.numel () >= 3) { glClearColor (c(0), c(1), c(2), 1); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/gl-render.h --- a/libinterp/corefcn/gl-render.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/gl-render.h Sat May 30 05:39:47 2015 -0400 @@ -71,7 +71,7 @@ virtual void draw (const Matrix& hlist, bool toplevel = false) { - int len = hlist.length (); + int len = hlist.numel (); for (int i = len-1; i >= 0; i--) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/graphics.cc Sat May 30 05:39:47 2015 -0400 @@ -9566,7 +9566,7 @@ fcn = c(0).function_value (); if (! error_state) { - for (int i = 1; i < c.length () ; i++) + for (int i = 1; i < c.numel () ; i++) args(1+i) = c(i); } } @@ -9865,7 +9865,7 @@ if (! error_state) { // loop over graphics objects - for (octave_idx_type n = 0; n < hcv.length (); n++) + for (octave_idx_type n = 0; n < hcv.numel (); n++) gh_manager::get_object (hcv(n)).reset_default_properties (); if (! error_state) @@ -10080,7 +10080,7 @@ bool request_drawnow = false; // loop over graphics objects - for (octave_idx_type n = 0; n < hcv.length (); n++) + for (octave_idx_type n = 0; n < hcv.numel (); n++) { graphics_object obj = gh_manager::get_object (hcv(n)); @@ -10094,7 +10094,7 @@ obj.set (args(1).cellstr_value (), args(2).cell_value (), 0); } - else if (hcv.length () == args(2).cell_value ().rows ()) + else if (hcv.numel () == args(2).cell_value ().rows ()) { obj.set (args(1).cellstr_value (), args(2).cell_value (), n); @@ -10102,7 +10102,7 @@ else { error ("set: number of graphics handles must match number of value rows (%d != %d)", - hcv.length (), args(2).cell_value ().rows ()); + hcv.numel (), args(2).cell_value ().rows ()); break; } @@ -10232,7 +10232,7 @@ if (! error_state) { - octave_idx_type len = hcv.length (); + octave_idx_type len = hcv.numel (); if (nargin == 1 && len > 1) { @@ -10396,7 +10396,7 @@ if (! error_state) { - octave_idx_type len = hcv.length (); + octave_idx_type len = hcv.numel (); vals.resize (dim_vector (len, 1)); @@ -10630,7 +10630,7 @@ { Matrix kids = go.get_properties ().get_children (); - for (octave_idx_type i = 0; i < kids.length (); i++) + for (octave_idx_type i = 0; i < kids.numel (); i++) { graphics_handle hnd = gh_manager::lookup (kids(i)); @@ -11197,7 +11197,7 @@ { Matrix hlist = gh_manager::figure_handle_list (true); - for (int i = 0; ! error_state && i < hlist.length (); i++) + for (int i = 0; ! error_state && i < hlist.numel (); i++) { graphics_handle h = gh_manager::lookup (hlist(i)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/graphics.in.h Sat May 30 05:39:47 2015 -0400 @@ -536,10 +536,10 @@ { std::string s; - for (octave_idx_type i = 0; i < str.length (); i++) + for (octave_idx_type i = 0; i < str.numel (); i++) { s += str[i]; - if (i != str.length () - 1) + if (i != str.numel () - 1) s += separator; } @@ -636,9 +636,9 @@ string_vector strings = new_cell.cellstr_value (); - octave_idx_type nel = strings.length (); - - if (nel != str.length ()) + octave_idx_type nel = strings.numel (); + + if (nel != str.numel ()) replace = true; else { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/help.cc --- a/libinterp/corefcn/help.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/help.cc Sat May 30 05:39:47 2015 -0400 @@ -797,22 +797,22 @@ string_vector make_name_list (void) { - const int key_len = keyword_names.length (); + const int key_len = keyword_names.numel (); const string_vector bif = symbol_table::built_in_function_names (); - const int bif_len = bif.length (); + const int bif_len = bif.numel (); const string_vector cfl = symbol_table::cmdline_function_names (); - const int cfl_len = cfl.length (); + const int cfl_len = cfl.numel (); const string_vector lcl = symbol_table::variable_names (); - const int lcl_len = lcl.length (); + const int lcl_len = lcl.numel (); const string_vector ffl = load_path::fcn_names (); - const int ffl_len = ffl.length (); + const int ffl_len = ffl.numel (); const string_vector afl = autoloaded_functions (); - const int afl_len = afl.length (); + const int afl_len = afl.numel (); const int total_len = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len; @@ -1303,7 +1303,7 @@ if (! error_state) { - int argc = argv.length (); + int argc = argv.numel (); if (argc > 1) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/hex2num.cc --- a/libinterp/corefcn/hex2num.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/hex2num.cc Sat May 30 05:39:47 2015 -0400 @@ -242,7 +242,7 @@ if (! error_state) { octave_idx_type nchars = 8; - octave_idx_type nr = v.length (); + octave_idx_type nr = v.numel (); charMatrix m (nr, nchars); const float *pv = v.fortran_vec (); @@ -279,7 +279,7 @@ if (! error_state) { octave_idx_type nchars = 16; - octave_idx_type nr = v.length (); + octave_idx_type nr = v.numel (); charMatrix m (nr, nchars); const double *pv = v.fortran_vec (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/input.cc Sat May 30 05:39:47 2015 -0400 @@ -408,13 +408,13 @@ else name_list = generate_possible_completions (text, prefix, hint); - name_list_len = name_list.length (); + name_list_len = name_list.numel (); file_name_list = command_editor::generate_filename_completions (text); name_list.append (file_name_list); - name_list_total_len = name_list.length (); + name_list_total_len = name_list.numel (); hint_len = hint.length (); @@ -1098,7 +1098,7 @@ // because it will be easier for Emacs if the names // appear in a single column. - int len = list.length (); + int len = list.numel (); for (int i = 0; i < len; i++) octave_stdout << list[i] << "\n"; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/jit-typeinfo.cc --- a/libinterp/corefcn/jit-typeinfo.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/jit-typeinfo.cc Sat May 30 05:39:47 2015 -0400 @@ -257,7 +257,7 @@ double value) { NDArray *array = mat->array; - if (array->nelem () < index) + if (array->numel () < index) array->resize1 (index); double *data = array->fortran_vec (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/jit-typeinfo.h --- a/libinterp/corefcn/jit-typeinfo.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/jit-typeinfo.h Sat May 30 05:39:47 2015 -0400 @@ -79,7 +79,7 @@ { ref_count = array->jit_ref_count (); slice_data = array->jit_slice_data () - 1; - slice_len = array->capacity (); + slice_len = array->numel (); dimensions = array->jit_dimensions (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/load-path.cc --- a/libinterp/corefcn/load-path.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/load-path.cc Sat May 30 05:39:47 2015 -0400 @@ -180,7 +180,7 @@ { string_vector flist = dir.read (); - octave_idx_type len = flist.length (); + octave_idx_type len = flist.numel (); all_files.resize (len); fcn_files.resize (len); @@ -250,7 +250,7 @@ { string_vector flist = dir.read (); - octave_idx_type len = flist.length (); + octave_idx_type len = flist.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -408,7 +408,7 @@ load_path::loader::move_fcn_map (const std::string& dir_name, const string_vector& fcn_files, bool at_end) { - octave_idx_type len = fcn_files.length (); + octave_idx_type len = fcn_files.numel (); for (octave_idx_type k = 0; k < len; k++) { @@ -803,7 +803,7 @@ load_path::loader::remove_fcn_map (const std::string& dir, const string_vector& fcn_files) { - octave_idx_type len = fcn_files.length (); + octave_idx_type len = fcn_files.numel (); for (octave_idx_type k = 0; k < len; k++) { @@ -1373,7 +1373,7 @@ { string_vector all_files = p->all_files; - octave_idx_type len = all_files.length (); + octave_idx_type len = all_files.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -1488,7 +1488,7 @@ std::string dir_name; std::string file_name; - octave_idx_type flen = flist.length (); + octave_idx_type flen = flist.numel (); octave_idx_type rel_flen = 0; string_vector rel_flist (flen); @@ -1534,7 +1534,7 @@ { string_vector all_files = p->all_files; - octave_idx_type len = all_files.length (); + octave_idx_type len = all_files.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -1567,7 +1567,7 @@ std::string dir_name; std::string file_name; - octave_idx_type flen = flist.length (); + octave_idx_type flen = flist.numel (); octave_idx_type rel_flen = 0; string_vector rel_flist (flen); @@ -1612,7 +1612,7 @@ { string_vector all_files = p->all_files; - octave_idx_type len = all_files.length (); + octave_idx_type len = all_files.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -1670,7 +1670,7 @@ if (omit_exts) { - octave_idx_type len = retval.length (); + octave_idx_type len = retval.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -1716,7 +1716,7 @@ string_vector xdirs = load_path::dirs (); - octave_idx_type len = xdirs.length (); + octave_idx_type len = xdirs.numel (); if (len > 0) xpath = xdirs[0]; @@ -1893,7 +1893,7 @@ string_vector fcn_files = di.fcn_files; - octave_idx_type len = fcn_files.length (); + octave_idx_type len = fcn_files.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -2150,7 +2150,7 @@ string_vector dirlist = dir.read ().sort (false); - octave_idx_type len = dirlist.length (); + octave_idx_type len = dirlist.numel (); for (octave_idx_type i = 0; i < len; i++) { @@ -2161,7 +2161,7 @@ if (! skip_p) { - for (octave_idx_type j = 0; j < skip.length (); j++) + for (octave_idx_type j = 0; j < skip.numel (); j++) { skip_p = (elt == skip[j]); if (skip_p) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/load-save.cc Sat May 30 05:39:47 2015 -0400 @@ -1052,7 +1052,7 @@ bool &save_as_floats, bool &use_zlib) { string_vector retval; - int argc = argv.length (); + int argc = argv.numel (); bool do_double = false; bool do_tabs = false; @@ -1634,7 +1634,7 @@ // override from command line argv = parse_save_options (argv, format, append, save_as_floats, use_zlib); - int argc = argv.length (); + int argc = argv.numel (); int i = 0; if (error_state) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/ls-mat4.cc --- a/libinterp/corefcn/ls-mat4.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/ls-mat4.cc Sat May 30 05:39:47 2015 -0400 @@ -498,7 +498,7 @@ Range r = tc.range_value (); double base = r.base (); double inc = r.inc (); - octave_idx_type nel = r.nelem (); + octave_idx_type nel = r.numel (); for (octave_idx_type i = 0; i < nel; i++) { double x = base + i * inc; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/ls-oct-ascii.h --- a/libinterp/corefcn/ls-oct-ascii.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/ls-oct-ascii.h Sat May 30 05:39:47 2015 -0400 @@ -158,7 +158,7 @@ std::string tmp = buf.str (); - for (int i = 0; i < keywords.length (); i++) + for (int i = 0; i < keywords.numel (); i++) { int match = (tmp == keywords[i]); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/lsode.cc --- a/libinterp/corefcn/lsode.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/lsode.cc Sat May 30 05:39:47 2015 -0400 @@ -88,7 +88,7 @@ retval = ColumnVector (tmp(0).vector_value ()); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("lsode"); } else @@ -127,7 +127,7 @@ retval = tmp(0).matrix_value (); - if (error_state || retval.length () == 0) + if (error_state || retval.numel () == 0) gripe_user_supplied_eval ("lsode"); } else @@ -300,9 +300,9 @@ if (f_arg.is_cell ()) { Cell c = f_arg.cell_value (); - if (c.length () == 1) + if (c.numel () == 1) f_arg = c(0); - else if (c.length () == 2) + else if (c.numel () == 2) { if (c(0).is_function_handle () || c(0).is_inline_function ()) lsode_fcn = c(0).function_value (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/lu.cc --- a/libinterp/corefcn/lu.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/lu.cc Sat May 30 05:39:47 2015 -0400 @@ -177,13 +177,13 @@ { if (!issparse) error ("lu: can not define pivoting threshold THRES for full matrices"); - else if (tmp.nelem () == 1) + else if (tmp.numel () == 1) { thres.resize (1,2); thres(0) = tmp(0); thres(1) = tmp(0); } - else if (tmp.nelem () == 2) + else if (tmp.numel () == 2) thres = tmp; else error ("lu: expecting 2-element vector for THRES"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/luinc.cc --- a/libinterp/corefcn/luinc.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/luinc.cc Sat May 30 05:39:47 2015 -0400 @@ -154,12 +154,12 @@ { thresh = tmp.matrix_value (); - if (thresh.nelem () == 1) + if (thresh.numel () == 1) { thresh.resize (1,2); thresh(1) = thresh(0); } - else if (thresh.nelem () != 2) + else if (thresh.numel () != 2) { error ("luinc: expecting 2-element vector for thresh"); return retval; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/matrix_type.cc --- a/libinterp/corefcn/matrix_type.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/matrix_type.cc Sat May 30 05:39:47 2015 -0400 @@ -292,7 +292,7 @@ error ("matrix_type: Invalid permutation vector PERM"); else { - octave_idx_type len = perm.length (); + octave_idx_type len = perm.numel (); dim_vector dv = args(0).dims (); if (len != dv(0)) @@ -465,7 +465,7 @@ error ("matrix_type: Invalid permutation vector PERM"); else { - octave_idx_type len = perm.length (); + octave_idx_type len = perm.numel (); dim_vector dv = args(0).dims (); if (len != dv(0)) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/max.cc --- a/libinterp/corefcn/max.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/max.cc Sat May 30 05:39:47 2015 -0400 @@ -271,7 +271,7 @@ if (arg.is_range () && (dim == -1 || dim == 1)) { Range range = arg.range_value (); - if (range.nelem () < 1) + if (range.numel () < 1) { retval(0) = arg; if (nargout > 1) @@ -282,14 +282,14 @@ retval(0) = range.min (); if (nargout > 1) retval(1) = static_cast - (range.inc () < 0 ? range.nelem () : 1); + (range.inc () < 0 ? range.numel () : 1); } else { retval(0) = range.max (); if (nargout > 1) retval(1) = static_cast - (range.inc () >= 0 ? range.nelem () : 1); + (range.inc () >= 0 ? range.numel () : 1); } } else if (arg.is_sparse_type ()) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/mgorth.cc --- a/libinterp/corefcn/mgorth.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/mgorth.cc Sat May 30 05:39:47 2015 -0400 @@ -45,7 +45,7 @@ h(Vc) = xnorm (x); if (real (h(Vc)) > 0) - x = x / h(Vc); + x /= h(Vc); } DEFUN (mgorth, args, nargout, diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/module.mk --- a/libinterp/corefcn/module.mk Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/module.mk Sat May 30 05:39:47 2015 -0400 @@ -233,6 +233,7 @@ corefcn/pr-output.cc \ corefcn/procstream.cc \ corefcn/profiler.cc \ + corefcn/psi.cc \ corefcn/quad.cc \ corefcn/quadcc.cc \ corefcn/qz.cc \ diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-hist.cc Sat May 30 05:39:47 2015 -0400 @@ -250,7 +250,7 @@ hlist = command_history::list (limit, numbered_output); - int len = hlist.length (); + int len = hlist.numel (); if (nargout == 0) { @@ -360,7 +360,7 @@ string_vector hlist = command_history::list (); - int hist_count = hlist.length () - 1; // switch to zero-based indexing + int hist_count = hlist.numel () - 1; // switch to zero-based indexing // The current command line is already part of the history list by // the time we get to this point. Delete the cmd from the list when diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-map.cc --- a/libinterp/corefcn/oct-map.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-map.cc Sat May 30 05:39:47 2015 -0400 @@ -142,7 +142,7 @@ Array& perm) const { octave_idx_type n = nfields (); - if (perm.length () != n) + if (perm.numel () != n) perm.clear (1, n); return equal_up_to_order (other, perm.fortran_vec ()); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-map.h --- a/libinterp/corefcn/oct-map.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-map.h Sat May 30 05:39:47 2015 -0400 @@ -161,7 +161,7 @@ octave_scalar_map (void) : xkeys (), xvals () { } octave_scalar_map (const string_vector& k) - : xkeys (k), xvals (k.length ()) { } + : xkeys (k), xvals (k.numel ()) { } octave_scalar_map (const octave_scalar_map& m) : xkeys (m.xkeys), xvals(m.xvals) { } @@ -277,10 +277,10 @@ octave_map (const dim_vector& dv) : xkeys (), xvals (), dimensions (dv) { } octave_map (const string_vector& k) - : xkeys (k), xvals (k.length (), Cell (1, 1)), dimensions (1, 1) { } + : xkeys (k), xvals (k.numel (), Cell (1, 1)), dimensions (1, 1) { } octave_map (const dim_vector& dv, const string_vector& k) - : xkeys (k), xvals (k.length (), Cell (dv)), dimensions (dv) { } + : xkeys (k), xvals (k.numel (), Cell (dv)), dimensions (dv) { } octave_map (const octave_map& m) : xkeys (m.xkeys), xvals (m.xvals), dimensions (m.dimensions) { } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-obj.h --- a/libinterp/corefcn/oct-obj.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-obj.h Sat May 30 05:39:47 2015 -0400 @@ -86,7 +86,7 @@ const octave_value& operator () (octave_idx_type n) const { return elem (n); } - octave_idx_type length (void) const { return data.length (); } + octave_idx_type length (void) const { return data.numel (); } bool empty (void) const { return length () == 0; } @@ -113,9 +113,9 @@ octave_value_list retval = data.linear_slice (offset, std::min (offset + len, length ())); - if (tags && len > 0 && names.length () > 0) + if (tags && len > 0 && names.numel () > 0) retval.names = names.linear_slice (offset, std::min (offset + len, - names.length ())); + names.numel ())); return retval; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-stream.cc Sat May 30 05:39:47 2015 -0400 @@ -123,7 +123,7 @@ double dnr = -1.0; double dnc = -1.0; - octave_idx_type sz_len = size.length (); + octave_idx_type sz_len = size.numel (); if (sz_len == 1) { @@ -235,7 +235,7 @@ scanf_format_list::~scanf_format_list (void) { - octave_idx_type n = list.length (); + octave_idx_type n = list.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -259,7 +259,7 @@ = new scanf_format_elt (text.c_str (), width, discard, type, modifier, char_class); - if (num_elts == list.length ()) + if (num_elts == list.numel ()) list.resize (dim_vector (2 * num_elts, 1)); list(num_elts++) = elt; @@ -342,13 +342,13 @@ else { char c = s[i++]; - width = width * 10 + c - '0'; + width = 10 * width + c - '0'; have_width = true; *buf << c; while (i < n && isdigit (s[i])) { c = s[i++]; - width = width * 10 + c - '0'; + width = 10 * width + c - '0'; *buf << c; } } @@ -489,7 +489,7 @@ void scanf_format_list::printme (void) const { - octave_idx_type n = list.length (); + octave_idx_type n = list.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -517,7 +517,7 @@ bool scanf_format_list::all_character_conversions (void) { - octave_idx_type n = list.length (); + octave_idx_type n = list.numel (); if (n > 0) { @@ -547,7 +547,7 @@ bool scanf_format_list::all_numeric_conversions (void) { - octave_idx_type n = list.length (); + octave_idx_type n = list.numel (); if (n > 0) { @@ -664,7 +664,7 @@ printf_format_list::~printf_format_list (void) { - octave_idx_type n = list.length (); + octave_idx_type n = list.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -688,7 +688,7 @@ = new printf_format_elt (text.c_str (), args, fw, prec, flags, type, modifier); - if (num_elts == list.length ()) + if (num_elts == list.numel ()) list.resize (dim_vector (2 * num_elts, 1)); list(num_elts++) = elt; @@ -871,7 +871,7 @@ void printf_format_list::printme (void) const { - int n = list.length (); + int n = list.numel (); for (int i = 0; i < n; i++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/oct-stream.h --- a/libinterp/corefcn/oct-stream.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/oct-stream.h Sat May 30 05:39:47 2015 -0400 @@ -116,7 +116,7 @@ // the list is 3 because of the characters that appear after the // last conversion. - octave_idx_type length (void) { return list.length (); } + octave_idx_type length (void) { return list.numel (); } const scanf_format_elt *first (void) { @@ -125,13 +125,13 @@ } const scanf_format_elt *current (void) const - { return list.length () > 0 ? list.elem (curr_idx) : 0; } + { return list.numel () > 0 ? list.elem (curr_idx) : 0; } const scanf_format_elt *next (bool cycle = true) { curr_idx++; - if (curr_idx >= list.length ()) + if (curr_idx >= list.numel ()) { if (cycle) curr_idx = 0; @@ -260,13 +260,13 @@ } const printf_format_elt *current (void) const - { return list.length () > 0 ? list.elem (curr_idx) : 0; } + { return list.numel () > 0 ? list.elem (curr_idx) : 0; } const printf_format_elt *next (bool cycle = true) { curr_idx++; - if (curr_idx >= list.length ()) + if (curr_idx >= list.numel ()) { if (cycle) curr_idx = 0; @@ -277,7 +277,7 @@ return current (); } - bool last_elt_p (void) { return (curr_idx + 1 == list.length ()); } + bool last_elt_p (void) { return (curr_idx + 1 == list.numel ()); } void printme (void) const; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/pr-output.cc Sat May 30 05:39:47 2015 -0400 @@ -393,8 +393,8 @@ } frac = flip - step; - n = n * step + lastn; - d = d * step + lastd; + n = step * n + lastn; + d = step * d + lastd; lastn = nextn; lastd = nextd; @@ -2664,7 +2664,7 @@ double base = r.base (); double increment = r.inc (); double limit = r.limit (); - octave_idx_type num_elem = r.nelem (); + octave_idx_type num_elem = r.numel (); if (plus_format && ! pr_as_read_syntax) { @@ -2886,7 +2886,7 @@ if (nda.is_empty ()) print_empty_nd_array (os, nda.dims (), pr_as_read_syntax); - else if (nda.length () == 1) + else if (nda.numel () == 1) { os << nda(0); } @@ -3155,7 +3155,7 @@ if (nda.is_empty ()) print_empty_nd_array (os, nda.dims (), pr_as_read_syntax); - else if (nda.length () == 1) + else if (nda.numel () == 1) octave_print_internal_template (os, nda(0), pr_as_read_syntax); else if (plus_format && ! pr_as_read_syntax) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/psi.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/corefcn/psi.cc Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,240 @@ +/* + +Copyright (C) 2015 Carnë Draug + +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 +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "ov.h" +#include "defun.h" +#include "error.h" +#include "dNDArray.h" +#include "fNDArray.h" + +#include "lo-specfun.h" + +DEFUN (psi, args, , +"-*- texinfo -*-\n\ +@deftypefn {Function File} {} psi (@var{z})\n\ +@deftypefnx {Function File} {} psi (@var{k}, @var{z})\n\ +Compute the psi (polygamma) function.\n\ +\n\ +The polygamma functions are the @var{k}th derivative of the logarithm\n\ +of the gamma function. If unspecified, @var{k} defaults to zero. A value\n\ +of zero computes the digamma function, a value of 1, the trigamma function,\n\ +and so on.\n\ +\n\ +The digamma function is defined:\n\ +\n\ +@tex\n\ +$$\n\ +\\Psi (z) = {d (log (\\Gamma (z))) \\over dx}\n\ +$$\n\ +@end tex\n\ +@ifnottex\n\ +@example\n\ +@group\n\ +psi (z) = d (log (gamma (z))) / dx\n\ +@end group\n\ +@end example\n\ +@end ifnottex\n\ +\n\ +When computing the digamma function (when @var{k} equals zero), @var{z}\n\ +can have any value real or complex value. However, for polygamma functions\n\ +(@var{k} higher than 0), @var{z} must be real and non-negative.\n\ +\n\ +@seealso{gamma, gammainc, gammaln}\n\ +@end deftypefn") +{ + octave_value retval; + + const octave_idx_type nargin = args.length (); + if (nargin < 1 || nargin > 2) + { + print_usage (); + return retval; + } + + const octave_value oct_z = (nargin == 1) ? args(0) : args(1); + const octave_idx_type k = (nargin == 1) ? 0 : args(0).idx_type_value (); + if (error_state || k < 0) + { + error ("psi: K must be a non-negative integer"); + return retval; + } + else if (k == 0) + { +#define FLOAT_BRANCH(T, A, M, E) \ + if (oct_z.is_ ## T ##_type ()) \ + { \ + const A ## NDArray z = oct_z.M ## array_value (); \ + A ## NDArray psi_z (z.dims ()); \ +\ + const E* zv = z.data (); \ + E* psi_zv = psi_z.fortran_vec (); \ + const octave_idx_type n = z.numel (); \ + for (octave_idx_type i = 0; i < n; i++) \ + *psi_zv++ = psi (*zv++); \ +\ + retval = psi_z; \ + } + + if (oct_z.is_complex_type ()) + { + FLOAT_BRANCH(double, Complex, complex_, Complex) + else FLOAT_BRANCH(single, FloatComplex, float_complex_, FloatComplex) + else + { + error ("psi: Z must be a floating point"); + } + } + else + { + FLOAT_BRANCH(double, , , double) + else FLOAT_BRANCH(single, Float, float_, float) + else + { + error ("psi: Z must be a floating point"); + } + } + +#undef FLOAT_BRANCH + } + else + { + if (! oct_z.is_real_type ()) + { + error ("psi: Z must be real value for polygamma (K > 0)"); + return retval; + } + +#define FLOAT_BRANCH(T, A, M, E) \ + if (oct_z.is_ ## T ##_type ()) \ + { \ + const A ## NDArray z = oct_z.M ## array_value (); \ + A ## NDArray psi_z (z.dims ()); \ +\ + const E* zv = z.data (); \ + E* psi_zv = psi_z.fortran_vec (); \ + const octave_idx_type n = z.numel (); \ + for (octave_idx_type i = 0; i < n; i++) \ + { \ + if (*zv < 0) \ + { \ + error ("psi: Z must be non-negative for polygamma (K > 0)"); \ + return retval; \ + } \ + *psi_zv++ = psi (k, *zv++); \ + } \ + retval = psi_z; \ + } + + FLOAT_BRANCH(double, , , double) + else FLOAT_BRANCH(single, Float, float_, float) + else + { + error ("psi: Z must be a floating point for polygamma (K > 0)"); + } + +#undef FLOAT_BRANCH + } + + return retval; +} + +/* +%!shared em +%! em = 0.577215664901532860606512090082402431042; # Euler-Mascheroni Constant + +%!assert (psi (ones (7, 3, 5)), repmat (-em, [7 3 5])) +%!assert (psi ([0 1]), [-Inf -em]) +%!assert (psi ([-20:1]), [repmat(-Inf, [1 21]) -em]) +%!assert (psi (single ([0 1])), single ([-Inf -em])) + +## Abramowitz and Stegun, page 258, eq 6.3.5 +%!test +%! z = [-10:.1:-.1 .1:.1:20]; # drop the 0 +%! assert (psi (z + 1), psi (z) + 1 ./ z, eps*1000) + +## Abramowitz and Stegun, page 258, eq 6.3.2 +%!assert (psi (1), -em) + +## Abramowitz and Stegun, page 258, eq 6.3.3 +%!assert (psi (1/2), -em - 2 * log (2)) + +## The following tests are from Pascal Sebah and Xavier Gourdon (2002) +## "Introduction to the Gamma Function" + +## Interesting identities of the digamma function, in section of 5.1.3 +%!assert (psi (1/3), - em - (3/2) * log(3) - ((sqrt (3) / 6) * pi), eps*10) +%!assert (psi (1/4), - em -3 * log (2) - pi /2) +%!assert (psi (1/6), - em -2 * log (2) - (3/2) * log (3) - ((sqrt (3) / 2) * pi), eps*10) + +## First 6 zeros of the digamma function, in section of 5.1.5 (and also on +## Abramowitz and Stegun, page 258, eq 6.3.19) +%!assert (psi ( 1.46163214496836234126265954232572132846819620400644), 0, eps) +%!assert (psi (-0.504083008264455409258269304533302498955385182368579), 0, eps) +%!assert (psi (-1.573498473162390458778286043690434612655040859116846), 0, eps) +%!assert (psi (-2.610720868444144650001537715718724207951074010873480), 0, eps*10) +%!assert (psi (-3.635293366436901097839181566946017713948423861193530), 0, eps*10) +%!assert (psi (-4.653237761743142441714598151148207363719069416133868), 0, eps*100) + +## Tests for complex values +%!shared z +%! z = [-10:.1:-.1 .1:.1:20]; # drop the 0 + +## Abramowitz and Stegun, page 259 eq 6.3.10 +%!assert (real (psi (i*z)), real (psi (1 - i*z))) + +## Abramowitz and Stegun, page 259 eq 6.3.11 +%!assert (imag (psi (i*z)), 1/2 .* 1./z + 1/2 * pi * coth (pi * z), eps *10) + +## Abramowitz and Stegun, page 259 eq 6.3.12 +%!assert (imag (psi (1/2 + i*z)), 1/2 * pi * tanh (pi * z), eps) + +## Abramowitz and Stegun, page 259 eq 6.3.13 +%!assert (imag (psi (1 + i*z)), - 1./(2*z) + 1/2 * pi * coth (pi * z), eps*10) + +## Abramowitz and Stegun, page 260 eq 6.4.5 +%!test +%! for z = 0:20 +%! assert (psi (1, z + 0.5), 0.5 * (pi^2) - 4 * sum ((2*(1:z) -1) .^(-2)), eps*10) +%! endfor + +## Abramowitz and Stegun, page 260 eq 6.4.6 +%!test +%! z = 0.1:0.1:20; +%! for n = 0:8 +%! ## our precision goes down really quick when computing n is too high, +%! assert (psi (n, z+1), psi (n, z) + ((-1)^n) * factorial (n) * (z.^(-n-1)), 0.1) +%! endfor + +## Test input validation +%!error psi () +%!error psi (1, 2, 3) +%!error psi ("non numeric") +%!error psi (-5, 1) +%!error psi (5, -1) +%!error psi (5, uint8 (-1)) +%!error psi (5, 5i) + +*/ diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/quad.cc --- a/libinterp/corefcn/quad.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/quad.cc Sat May 30 05:39:47 2015 -0400 @@ -312,7 +312,7 @@ if (error_state) QUAD_ABORT1 ("expecting vector of tolerances as fifth argument"); - switch (tol.capacity ()) + switch (tol.numel ()) { case 2: quad_opts.set_single_precision_relative_tolerance (tol (1)); @@ -421,7 +421,7 @@ if (error_state) QUAD_ABORT1 ("expecting vector of tolerances as fifth argument"); - switch (tol.capacity ()) + switch (tol.numel ()) { case 2: quad_opts.set_relative_tolerance (tol (1)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/quadcc.cc --- a/libinterp/corefcn/quadcc.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/quadcc.cc Sat May 30 05:39:47 2015 -0400 @@ -1713,7 +1713,7 @@ return retval; } Matrix effex = fvals(0).matrix_value (); - if (effex.length () != ex.length ()) + if (effex.numel () != ex.numel ()) { error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); return retval; @@ -1832,12 +1832,12 @@ return retval; } Matrix effex = fvals(0).matrix_value (); - if (effex.length () != ex.length ()) + if (effex.numel () != ex.numel ()) { error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); return retval; } - neval += effex.length (); + neval += effex.numel (); for (i = 0; i < n[d] / 2; i++) { j = (2 * i + 1) * skip[d]; @@ -1980,12 +1980,12 @@ return retval; } Matrix effex = fvals(0).matrix_value (); - if (effex.length () != ex.length ()) + if (effex.numel () != ex.numel ()) { error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); return retval; } - neval += effex.length (); + neval += effex.numel (); for (i = 0; i < n[0] - 1; i++) { j = (i + 1) * skip[0]; @@ -2076,12 +2076,12 @@ return retval; } Matrix effex = fvals(0).matrix_value (); - if (effex.length () != ex.length ()) + if (effex.numel () != ex.numel ()) { error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input"); return retval; } - neval += effex.length (); + neval += effex.numel (); for (i = 0; i < n[0] - 1; i++) { j = (i + 1) * skip[0]; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/rand.cc --- a/libinterp/corefcn/rand.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/rand.cc Sat May 30 05:39:47 2015 -0400 @@ -190,7 +190,7 @@ if (r.all_elements_are_ints ()) { - octave_idx_type n = r.nelem (); + octave_idx_type n = r.numel (); dims.resize (n); @@ -218,7 +218,7 @@ if (! error_state) { - octave_idx_type len = iv.length (); + octave_idx_type len = iv.numel (); dims.resize (len); @@ -317,7 +317,7 @@ { if (additional_arg) { - if (a.length () == 1) + if (a.numel () == 1) return octave_rand::float_nd_array (dims, a(0)); else { @@ -326,7 +326,7 @@ error ("%s: mismatch in argument size", fcn); return retval; } - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); FloatNDArray m (dims); float *v = m.fortran_vec (); for (octave_idx_type i = 0; i < len; i++) @@ -341,7 +341,7 @@ { if (additional_arg) { - if (a.length () == 1) + if (a.numel () == 1) return octave_rand::nd_array (dims, a(0)); else { @@ -350,7 +350,7 @@ error ("%s: mismatch in argument size", fcn); return retval; } - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); NDArray m (dims); double *v = m.fortran_vec (); for (octave_idx_type i = 0; i < len; i++) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/regexp.cc --- a/libinterp/corefcn/regexp.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/regexp.cc Sat May 30 05:39:47 2015 -0400 @@ -77,13 +77,38 @@ retval[++i] = 'b'; break; -#if 0 -// FIXME: To be complete, we need to handle \oN, \o{N}. -// The PCRE library already handles \N where N -// is an octal number. New code needs to merely -// replace \oN or \o{N} with \N. - case 'o': // octal number -#endif + case 'o': // octal input + { + bool bad_esc_seq = (j+1 >= len); + + bool brace = false; + if (! bad_esc_seq && s[++j] == '{') + { + brace = true; + j++; + } + + int tmpi = 0; + size_t k; + for (k = j; k < std::min (j+3+brace, len); k++) + { + int digit = s[k] - '0'; + if (digit < 0 || digit > 7) + break; + tmpi <<= 3; + tmpi += digit; + } + if (bad_esc_seq || (brace && s[k++] != '}')) + { + bad_esc_seq = true; + tmpi = 0; + warning ("malformed octal escape sequence '\\o' --\ + converting to '\\0'"); + } + retval[i] = tmpi; + j = k - 1; + break; + } default: // pass escape sequence through retval[i] = '\\'; @@ -150,14 +175,75 @@ retval[i] = '\v'; break; -#if 0 -// FIXME: to be complete, we need to handle \oN, \o{N}, \xN, and -// \x{N}. Hex digits may be upper or lower case. Brackets are -// optional, so \x5Bz is the same as \x{5B}z. + case 'o': // octal input + { + bool bad_esc_seq = (j+1 >= len); + + bool brace = false; + if (! bad_esc_seq && s[++j] == '{') + { + brace = true; + j++; + } + + int tmpi = 0; + size_t k; + for (k = j; k < std::min (j+3+brace, len); k++) + { + int digit = s[k] - '0'; + if (digit < 0 || digit > 7) + break; + tmpi <<= 3; + tmpi += digit; + } + if (bad_esc_seq || (brace && s[k++] != '}')) + { + warning ("malformed octal escape sequence '\\o' --\ + converting to '\\0'"); + tmpi = 0; + } + retval[i] = tmpi; + j = k - 1; + break; + } - case 'o': // octal number - case 'x': // hex number -#endif + case 'x': // hex input + { + bool bad_esc_seq = (j+1 >= len); + + bool brace = false; + if (! bad_esc_seq && s[++j] == '{') + { + brace = true; + j++; + } + + int tmpi = 0; + size_t k; + for (k = j; k < std::min (j+2+brace, len); k++) + { + if (! isxdigit (s[k])) + break; + + tmpi <<= 4; + int digit = s[k]; + if (digit >= 'a') + tmpi += digit - 'a' + 10; + else if (digit >= 'A') + tmpi += digit - 'A' + 10; + else + tmpi += digit - '0'; + } + if (bad_esc_seq || (brace && s[k++] != '}')) + { + warning ("malformed hex escape sequence '\\x' --\ + converting to '\\0'"); + tmpi = 0; + } + retval[i] = tmpi; + j = k - 1; + break; + } default: // pass escape sequence through retval[i] = '\\'; @@ -282,14 +368,14 @@ { string_vector named_tokens = rx_lst.begin ()->named_tokens (); - for (int j = 0; j < named_pats.length (); j++) + for (int j = 0; j < named_pats.numel (); j++) nmap.assign (named_pats(j), named_tokens(j)); retval(5) = nmap; } else { - for (int j = 0; j < named_pats.length (); j++) + for (int j = 0; j < named_pats.numel (); j++) { Cell tmp (dim_vector (1, sz)); @@ -354,7 +440,7 @@ double e = p->end (); string_vector tmp = p->tokens (); - tokens(i) = Cell (dim_vector (1, tmp.length ()), tmp); + tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp); match_string(i) = p->match_string (); token_extents(i) = p->token_extents (); end(i) = e; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/strfns.cc --- a/libinterp/corefcn/strfns.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/strfns.cc Sat May 30 05:39:47 2015 -0400 @@ -103,8 +103,8 @@ return retval; } - if (s.length () > 0) - n_elts += s.length (); + if (s.numel () > 0) + n_elts += s.numel (); else n_elts += 1; @@ -125,7 +125,7 @@ string_vector s = args_as_strings.front (); args_as_strings.pop (); - int n = s.length (); + int n = s.numel (); if (n > 0) { @@ -210,78 +210,70 @@ octave_value retval; int nargin = args.length (); - - if (nargin > 0) - { - int n_elts = 0; - - size_t max_len = 0; - - std::queue args_as_strings; + int n_elts = 0; + size_t max_len = 0; + std::queue args_as_strings; - for (int i = 0; i < nargin; i++) - { - string_vector s = args(i).all_strings (); - - if (error_state) - { - error ("strvcat: unable to convert some args to strings"); - return retval; - } + for (int i = 0; i < nargin; i++) + { + string_vector s = args(i).all_strings (); - size_t n = s.length (); + if (error_state) + { + error ("strvcat: unable to convert some args to strings"); + return retval; + } - // do not count empty strings in calculation of number of elements - if (n > 0) + size_t n = s.numel (); + + // do not count empty strings in calculation of number of elements + if (n > 0) + { + for (size_t j = 0; j < n; j++) { - for (size_t j = 0; j < n; j++) - { - if (s[j].length () > 0) - n_elts++; - } + if (s[j].length () > 0) + n_elts++; } - - size_t s_max_len = s.max_length (); - - if (s_max_len > max_len) - max_len = s_max_len; - - args_as_strings.push (s); } - string_vector result (n_elts); + size_t s_max_len = s.max_length (); + + if (s_max_len > max_len) + max_len = s_max_len; + + args_as_strings.push (s); + } + + string_vector result (n_elts); - octave_idx_type k = 0; + octave_idx_type k = 0; - for (int i = 0; i < nargin; i++) + for (int i = 0; i < nargin; i++) + { + string_vector s = args_as_strings.front (); + args_as_strings.pop (); + + size_t n = s.numel (); + + if (n > 0) { - string_vector s = args_as_strings.front (); - args_as_strings.pop (); - - size_t n = s.length (); - - if (n > 0) + for (size_t j = 0; j < n; j++) { - for (size_t j = 0; j < n; j++) + std::string t = s[j]; + if (t.length () > 0) { - std::string t = s[j]; - if (t.length () > 0) - { - size_t t_len = t.length (); + size_t t_len = t.length (); - if (max_len > t_len) - t += std::string (max_len - t_len, ' '); + if (max_len > t_len) + t += std::string (max_len - t_len, ' '); - result[k++] = t; - } + result[k++] = t; } } } + } - retval = octave_value (result, '\''); - } - else - print_usage (); + retval = octave_value (result, '\''); return retval; } @@ -298,8 +290,7 @@ %!assert (strvcat ({100,{100, {""}}}), ["d";"d"]) %!assert (strvcat (["a";"be"], {"c", 100}), ["a";"be";"c";"d"]) %!assert (strvcat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"]) - -%!error strvcat () +%!assert (strvcat (), "") */ @@ -374,7 +365,7 @@ const Cell cell = cell_val.cell_value (); const string_vector str = str_val.all_strings (); - octave_idx_type r = str.length (); + octave_idx_type r = str.numel (); if (r == 0 || r == 1) { @@ -387,13 +378,13 @@ if (cell_val.is_cellstr ()) { const Array cellstr = cell_val.cellstr_value (); - for (octave_idx_type i = 0; i < cellstr.length (); i++) + for (octave_idx_type i = 0; i < cellstr.numel (); i++) output(i) = str_op (cellstr(i), s, n); } else { // FIXME: should we warn here? - for (octave_idx_type i = 0; i < cell.length (); i++) + for (octave_idx_type i = 0; i < cell.numel (); i++) { if (cell(i).is_string ()) output(i) = str_op (cell(i).string_value (), s, n); @@ -404,7 +395,7 @@ } else if (r > 1) { - if (cell.length () == 1) + if (cell.numel () == 1) { // Broadcast the cell. @@ -427,13 +418,13 @@ boolNDArray output (cell.dims (), false); - if (cell.length () == r) + if (cell.numel () == r) { if (cell_val.is_cellstr ()) { const Array cellstr = cell_val.cellstr_value (); - for (octave_idx_type i = 0; i < cellstr.length (); i++) + for (octave_idx_type i = 0; i < cellstr.numel (); i++) output(i) = str_op (str[i], cellstr(i), n); } else @@ -493,7 +484,7 @@ if (cell1_val.is_cellstr ()) { const Array cellstr = cell1_val.cellstr_value (); - for (octave_idx_type i = 0; i < cellstr.length (); i++) + for (octave_idx_type i = 0; i < cellstr.numel (); i++) output(i) = str_op (cellstr(i), str2, n); } else diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/sub2ind.cc --- a/libinterp/corefcn/sub2ind.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/sub2ind.cc Sat May 30 05:39:47 2015 -0400 @@ -39,7 +39,7 @@ { RowVector dimsv = val.row_vector_value (false, true); dim_vector dv; - octave_idx_type n = dimsv.length (); + octave_idx_type n = dimsv.numel (); if (n < 1) error ("%s: dimension vector DIMS must not be empty", name); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/symtab.cc --- a/libinterp/corefcn/symtab.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/symtab.cc Sat May 30 05:39:47 2015 -0400 @@ -44,6 +44,7 @@ #include "pager.h" #include "parse.h" #include "pt-arg-list.h" +#include "pt-pr-code.h" #include "symtab.h" #include "unwind-prot.h" #include "utils.h" @@ -1810,6 +1811,44 @@ return retval; } +DEFUN (__get_cmdline_fcn_txt__, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} __get_cmdline_fcn_txt__ (@var{name})\n\ +Undocumented internal function.\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + { + std::string name = args(0).string_value (); + + if (! error_state) + { + octave_value ov = symbol_table::find_cmdline_function (name); + + octave_user_function *f = ov.user_function_value (); + + if (f) + { + std::ostringstream buf; + + tree_print_code tpc (buf); + + f->accept (tpc); + + retval = buf.str (); + } + } + else + error ("__get_cmd_line_function_text__: expecting function name"); + } + else + print_usage (); + + return retval; +} + #if 0 // FIXME: should we have functions like this in Octave? diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/symtab.h --- a/libinterp/corefcn/symtab.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/symtab.h Sat May 30 05:39:47 2015 -0400 @@ -1548,6 +1548,14 @@ ? p->second.find_user_function () : octave_value (); } + static octave_value find_cmdline_function (const std::string& name) + { + fcn_table_iterator p = fcn_table.find (name); + + return (p != fcn_table.end ()) + ? p->second.find_cmdline_function () : octave_value (); + } + static void install_cmdline_function (const std::string& name, const octave_value& fcn) { @@ -2044,7 +2052,7 @@ { std::list retval; - size_t len = patterns.length (); + size_t len = patterns.numel (); for (size_t i = 0; i < len; i++) { @@ -2061,7 +2069,7 @@ { std::list retval; - size_t len = patterns.length (); + size_t len = patterns.numel (); for (size_t i = 0; i < len; i++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/syscalls.cc --- a/libinterp/corefcn/syscalls.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/syscalls.cc Sat May 30 05:39:47 2015 -0400 @@ -204,7 +204,7 @@ if (! error_state) { - int len = tmp.length (); + int len = tmp.numel (); exec_args.resize (len + 1); @@ -316,7 +316,7 @@ if (! error_state) { - int len = tmp.length (); + int len = tmp.numel (); arg_list.resize (len + 1); @@ -819,15 +819,45 @@ return retval; } +// FIXME: This routine also exists verbatim in file-io.cc. +// Maybe change to be a general utility routine. +static int +convert (int x, int ibase, int obase) +{ + int retval = 0; + + int tmp = x % obase; + + if (tmp > ibase - 1) + ::error ("mkfifo: invalid digit"); + else + { + retval = tmp; + int mult = ibase; + while ((x = (x - tmp) / obase)) + { + tmp = x % obase; + if (tmp > ibase - 1) + { + ::error ("mkfifo: invalid digit"); + break; + } + retval += mult * tmp; + mult *= ibase; + } + } + + return retval; +} + DEFUNX ("mkfifo", Fmkfifo, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{err} =} mkfifo (@var{name}, @var{mode})\n\ @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ Create a FIFO special file named @var{name} with file mode @var{mode}.\n\ \n\ -@var{mode} is interpreted as a decimal number (@emph{not} octal) and is\n\ -subject to umask processing. The final calculated mode is\n\ -@code{@var{mode} - @var{umask}}.\n\ +@var{mode} is interpreted as an octal number and is subject to umask\n\ +processing. The final calculated mode is @code{@var{mode} - @var{umask}}.\n\ \n\ If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\ @@ -835,7 +865,7 @@ @seealso{pipe, umask}\n\ @end deftypefn") { - octave_value_list retval; + octave_value_list retval (2); retval(1) = std::string (); retval(0) = -1; @@ -848,23 +878,28 @@ { std::string name = args(0).string_value (); - if (args(1).is_scalar_type ()) - { - long mode = args(1).long_value (); + int octal_mode = args(1).int_value (); - if (! error_state) + if (! error_state) + { + if (octal_mode < 0) + error ("mkfifo: MODE must be a positive integer value"); + else { - std::string msg; + int mode = convert (octal_mode, 8, 10); - int status = octave_mkfifo (name, mode, msg); + if (! error_state) + { + std::string msg; - retval(0) = status; + int status = octave_mkfifo (name, mode, msg); - if (status < 0) - retval(1) = msg; + retval(0) = status; + + if (status < 0) + retval(1) = msg; + } } - else - error ("mkfifo: invalid MODE"); } else error ("mkfifo: MODE must be an integer"); @@ -878,6 +913,19 @@ return retval; } +/* + +## Test input validation +%!error mkfifo () +%!error mkfifo ("abc") +%!error mkfifo ("abc", 777, 123) +%!error mkfifo (123, 456) +## FIXME: These tests should work, but lasterr is not being set correctly. +#%!error mkfifo ("abc", {456}) +#%!error mkfifo ("abc", -1) + +*/ + DEFUNX ("pipe", Fpipe, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/tril.cc --- a/libinterp/corefcn/tril.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/tril.cc Sat May 30 05:39:47 2015 -0400 @@ -218,7 +218,7 @@ dim_vector dims = arg.dims (); if (dims.length () != 2) error ("%s: need a 2-D matrix", name.c_str ()); - else if (k < -dims (0) || k > dims(1)) + else if (k < -dims(0) || k > dims(1)) error ("%s: requested diagonal out of range", name.c_str ()); else { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/tsearch.cc --- a/libinterp/corefcn/tsearch.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/tsearch.cc Sat May 30 05:39:47 2015 -0400 @@ -103,7 +103,7 @@ maxy(k) = max (REF (y, k, 0), REF (y, k, 1), REF (y, k, 2)) + eps; } - const octave_idx_type np = xi.length (); + const octave_idx_type np = xi.numel (); ColumnVector values (np); double x0, y0, a11, a12, a21, a22, det; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/typecast.cc --- a/libinterp/corefcn/typecast.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/typecast.cc Sat May 30 05:39:47 2015 -0400 @@ -40,7 +40,7 @@ { if (old_dims.length () == 2 && old_dims(0) == 1) return dim_vector (1, n); - else if (old_dims.length () == 2 && old_dims (0) == 0 && old_dims (1) == 0) + else if (old_dims.length () == 2 && old_dims(0) == 0 && old_dims(1) == 0) return dim_vector (); else return dim_vector (n, 1); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/urlwrite.cc --- a/libinterp/corefcn/urlwrite.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/urlwrite.cc Sat May 30 05:39:47 2015 -0400 @@ -712,7 +712,7 @@ else { string_vector sv = curl.list (); - octave_idx_type n = sv.length (); + octave_idx_type n = sv.numel (); if (n == 0) { @@ -1050,7 +1050,7 @@ glob_match pattern (file_ops::tilde_expand (pat)); string_vector files = pattern.glob (); - for (octave_idx_type i = 0; i < files.length (); i++) + for (octave_idx_type i = 0; i < files.numel (); i++) { std::string file = files (i); @@ -1145,7 +1145,7 @@ glob_match pattern (file); - for (octave_idx_type i = 0; i < sv.length (); i++) + for (octave_idx_type i = 0; i < sv.numel (); i++) { if (pattern.match (sv(i))) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/utils.cc --- a/libinterp/corefcn/utils.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/utils.cc Sat May 30 05:39:47 2015 -0400 @@ -267,7 +267,7 @@ string_vector sv = p.find_all_first_of (names); - octave_idx_type len = sv.length (); + octave_idx_type len = sv.numel (); for (octave_idx_type i = 0; i < len; i++) sv[i] = octave_env::make_absolute (sv[i]); @@ -278,7 +278,7 @@ static string_vector make_absolute (const string_vector& sv) { - octave_idx_type len = sv.length (); + octave_idx_type len = sv.numel (); string_vector retval (len); @@ -316,7 +316,7 @@ { string_vector names = args(0).all_strings (); - if (! error_state && names.length () > 0) + if (! error_state && names.numel () > 0) { if (nargin == 1) retval = @@ -399,7 +399,7 @@ string_vector names = args(1).all_strings (); - if (! error_state && names.length () > 0) + if (! error_state && names.numel () > 0) { if (nargin == 2) retval = search_path_for_file (path, names); @@ -631,11 +631,7 @@ { switch (s[++j]) { - case '0': - retval[i] = '\0'; - break; - - case 'a': + case 'a': // alarm retval[i] = '\a'; break; @@ -675,6 +671,58 @@ retval[i] = '"'; break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': // octal input + { + size_t k; + int tmpi = s[j] - '0'; + for (k = j+1; k < std::min (j+3, len); k++) + { + int digit = s[k] - '0'; + if (digit < 0 || digit > 7) + break; + tmpi <<= 3; + tmpi += digit; + } + retval[i] = tmpi; + j = k - 1; + break; + } + + case 'x': // hex input + { + size_t k; + int tmpi = 0; + for (k = j+1; k < std::min (j+3, len); k++) + { + if (! isxdigit (s[k])) + break; + + tmpi <<= 4; + int digit = s[k]; + if (digit >= 'a') + tmpi += digit - 'a' + 10; + else if (digit >= 'A') + tmpi += digit - 'A' + 10; + else + tmpi += digit - '0'; + } + + if (k == j+1) + warning ("malformed hex escape sequence '\\x' --\ + converting to '\\0'"); + + retval[i] = tmpi; + j = k - 1; + break; + } + default: warning ("unrecognized escape sequence '\\%c' --\ converting to '%c'", s[j], s[j]); @@ -745,9 +793,20 @@ %!assert (do_string_escapes ('\"double-quoted\"'), "\"double-quoted\"") %!assert (do_string_escapes ("\\\"double-quoted\\\""), "\"double-quoted\"") +%!assert (do_string_escapes ('A\4B'), ["A" char(4) "B"]) +%!assert (do_string_escapes ('A\45B'), ["A" char(37) "B"]) +%!assert (do_string_escapes ('A\123B'), ["A" char(83) "B"]) +%!assert (sprintf ('\117\143\164\141\166\145'), "Octave") + +%!assert (do_string_escapes ('A\x4G'), ["A" char(4) "G"]) +%!assert (do_string_escapes ('A\x4AG'), ["A" char(74) "G"]) +%!assert (sprintf ('\x4f\x63\x74\x61\x76\x65'), "Octave") + %!error do_string_escapes () %!error do_string_escapes ("foo", "bar") -%!error do_string_escapes (3) +%!error do_string_escapes (3) +%!warning do_string_escapes ('\xG'); +%!warning do_string_escapes ('\G'); */ const char * @@ -1159,7 +1218,7 @@ if (error_state) return; - octave_idx_type n = v.length (); + octave_idx_type n = v.numel (); dim.resize (n); for (octave_idx_type i = 0; i < n; i++) dim(i) = static_cast (fix (v(i))); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/variables.cc Sat May 30 05:39:47 2015 -0400 @@ -395,6 +395,14 @@ bool search_dir = type == "dir"; bool search_file = type == "file"; bool search_builtin = type == "builtin"; + bool search_class = type == "class"; + + if (! (search_any || search_var || search_dir || search_file || + search_builtin || search_class)) + { + error ("exist: unrecognized type argument \"%s\"", type.c_str ()); + return 0; + } if (search_any || search_var) { @@ -682,6 +690,7 @@ %!warning <"class" type argument is not implemented> exist ("a", "class"); %!error exist ("a", 1) %!error exist (1) +%!error exist ("a", "foobar") */ @@ -1247,7 +1256,7 @@ break; case 'e': - os << varval.capacity (); + os << varval.numel (); break; case 'n': @@ -1395,7 +1404,7 @@ octave_value val = p->varval; - elements += val.capacity (); + elements += val.numel (); bytes += val.byte_size (); } @@ -1467,7 +1476,7 @@ > static_cast (param_length(pos_t))) ? str.length () : param_length(pos_t)); - elements1 = val.capacity (); + elements1 = val.numel (); ss1 << elements1; str = ss1.str (); param_length(pos_e) = ((str.length () @@ -2208,7 +2217,7 @@ { string_vector fcns = symbol_table::user_function_names (); - int fcount = fcns.length (); + int fcount = fcns.numel (); for (int i = 0; i < fcount; i++) { @@ -2234,7 +2243,7 @@ { string_vector gvars = symbol_table::global_variable_names (); - int gcount = gvars.length (); + int gcount = gvars.numel (); for (int i = 0; i < gcount; i++) symbol_table::clear_global (gvars[i]); @@ -2245,7 +2254,7 @@ { string_vector gvars = symbol_table::global_variable_names (); - int gcount = gvars.length (); + int gcount = gvars.numel (); for (int i = 0; i < gcount; i++) { @@ -2275,7 +2284,7 @@ { string_vector lvars = symbol_table::variable_names (); - int lcount = lvars.length (); + int lcount = lvars.numel (); for (int i = 0; i < lcount; i++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/xdiv.cc --- a/libinterp/corefcn/xdiv.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/xdiv.cc Sat May 30 05:39:47 2015 -0400 @@ -289,7 +289,7 @@ { NDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -303,7 +303,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -317,7 +317,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -331,7 +331,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -590,7 +590,7 @@ { FloatNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -604,7 +604,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -618,7 +618,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); @@ -632,7 +632,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = a / b (i); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/corefcn/xpow.cc --- a/libinterp/corefcn/xpow.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/corefcn/xpow.cc Sat May 30 05:39:47 2015 -0400 @@ -705,10 +705,10 @@ // Only optimize powers with ranges that are integer and monotonic in // magnitude. - if (r.nelem () > 1 && r.all_elements_are_ints () + if (r.numel () > 1 && r.all_elements_are_ints () && same_sign (r.base (), r.limit ())) { - octave_idx_type n = r.nelem (); + octave_idx_type n = r.numel (); Matrix result (1, n); if (same_sign (r.base (), r.inc ())) { @@ -940,10 +940,10 @@ // Only optimize powers with ranges that are integer and monotonic in // magnitude. - if (r.nelem () > 1 && r.all_elements_are_ints () + if (r.numel () > 1 && r.all_elements_are_ints () && same_sign (r.base (), r.limit ())) { - octave_idx_type n = r.nelem (); + octave_idx_type n = r.numel (); ComplexMatrix result (1, n); if (same_sign (r.base (), r.inc ())) @@ -1121,7 +1121,7 @@ { Complex atmp (a); ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (atmp, b(i)); @@ -1132,7 +1132,7 @@ else { NDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = std::pow (a, b(i)); @@ -1150,7 +1150,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (a, b(i)); @@ -1171,7 +1171,7 @@ { ComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); @@ -1185,7 +1185,7 @@ else { NDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -1201,22 +1201,22 @@ int ib = static_cast (b); if (ib == 2) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = a(i) * a(i); } else if (ib == 3) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = a(i) * a(i) * a(i); } else if (ib == -1) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = 1.0 / a(i); } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), ib); @@ -1257,7 +1257,7 @@ } } - int len = a.length (); + int len = a.numel (); bool convert_to_complex = false; @@ -1310,7 +1310,7 @@ { ComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -1341,7 +1341,7 @@ ComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b(i)); @@ -1356,7 +1356,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); double btmp = b(i); @@ -1375,7 +1375,7 @@ { ComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (a, b(i)); @@ -1394,12 +1394,12 @@ { if (b == -1) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result.xelem (i) = 1.0 / a(i); } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), static_cast (b)); @@ -1408,7 +1408,7 @@ } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -1440,7 +1440,7 @@ ComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); double btmp = b(i); @@ -1459,7 +1459,7 @@ { ComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -1490,7 +1490,7 @@ ComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b(i)); @@ -2471,7 +2471,7 @@ { FloatComplex atmp (a); FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (atmp, b(i)); @@ -2482,7 +2482,7 @@ else { FloatNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result (i) = std::pow (a, b(i)); @@ -2500,7 +2500,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (a, b(i)); @@ -2521,7 +2521,7 @@ { FloatComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); @@ -2535,7 +2535,7 @@ else { FloatNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -2551,22 +2551,22 @@ int ib = static_cast (b); if (ib == 2) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = a(i) * a(i); } else if (ib == 3) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = a(i) * a(i) * a(i); } else if (ib == -1) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result(i) = 1.0f / a(i); } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), ib); @@ -2607,7 +2607,7 @@ } } - int len = a.length (); + int len = a.numel (); bool convert_to_complex = false; @@ -2660,7 +2660,7 @@ { FloatComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -2691,7 +2691,7 @@ FloatComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b(i)); @@ -2706,7 +2706,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); float btmp = b(i); @@ -2725,7 +2725,7 @@ { FloatComplexNDArray result (b.dims ()); - for (octave_idx_type i = 0; i < b.length (); i++) + for (octave_idx_type i = 0; i < b.numel (); i++) { octave_quit (); result(i) = std::pow (a, b(i)); @@ -2744,12 +2744,12 @@ { if (b == -1) { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) result.xelem (i) = 1.0f / a(i); } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), static_cast (b)); @@ -2758,7 +2758,7 @@ } else { - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -2790,7 +2790,7 @@ FloatComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); float btmp = b(i); @@ -2809,7 +2809,7 @@ { FloatComplexNDArray result (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b); @@ -2840,7 +2840,7 @@ FloatComplexNDArray result (a_dims); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) { octave_quit (); result(i) = std::pow (a(i), b(i)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/__glpk__.cc --- a/libinterp/dldfcn/__glpk__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/__glpk__.cc Sat May 30 05:39:47 2015 -0400 @@ -470,7 +470,7 @@ //-- bound on each of the variables. Matrix LB (args(3).matrix_value ()); - if (error_state || LB.length () < mrowsc) + if (error_state || LB.numel () < mrowsc) { error ("__glpk__: invalid value of LB"); return retval; @@ -495,7 +495,7 @@ //-- bound on each of the variables. Matrix UB (args(4).matrix_value ()); - if (error_state || UB.length () < mrowsc) + if (error_state || UB.numel () < mrowsc) { error ("__glpk__: invalid value of UB"); return retval; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/__init_fltk__.cc --- a/libinterp/dldfcn/__init_fltk__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/__init_fltk__.cc Sat May 30 05:39:47 2015 -0400 @@ -563,7 +563,7 @@ { std::vector delayed_menus; Matrix kids = find_uimenu_children (uimenup); - int len = kids.length (); + int len = kids.numel (); std::string fltk_label = uimenup.get_fltk_label (); int count = 0; @@ -613,7 +613,7 @@ { std::vector delayed_menus; Matrix kids = find_uimenu_children (figp); - int len = kids.length (); + int len = kids.numel (); int count = 0; menubar->clear (); for (octave_idx_type ii = 0; ii < len; ii++) @@ -658,7 +658,7 @@ Matrix kids; std::string type = prop.get_type (); kids = find_uimenu_children (prop); - int len = kids.length (); + int len = kids.numel (); for (octave_idx_type ii = 0; ii < len; ii++) { @@ -1113,7 +1113,7 @@ graphics_handle pixel2axes_or_ca (int px, int py) { Matrix kids = fp.get_children (); - int len = kids.length (); + int len = kids.numel (); for (int k = 0; k < len; k++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/__magick_read__.cc Sat May 30 05:39:47 2015 -0400 @@ -177,8 +177,8 @@ (region["row_cache"] + rows.inc () -1) - cols.inc (); // The actual height and width of the output image - region["row_out"] = rows.nelem (); - region["col_out"] = cols.nelem (); + region["row_out"] = rows.numel (); + region["col_out"] = cols.numel (); return region; } @@ -216,7 +216,7 @@ octave_value_list retval (3, Matrix ()); std::map region = calculate_region (options); - const octave_idx_type nFrames = frameidx.length (); + const octave_idx_type nFrames = frameidx.numel (); const octave_idx_type nRows = region["row_out"]; const octave_idx_type nCols = region["col_out"]; @@ -311,7 +311,7 @@ octave_value_list retval (3, Matrix ()); std::map region = calculate_region (options); - const octave_idx_type nFrames = frameidx.length (); + const octave_idx_type nFrames = frameidx.numel (); const octave_idx_type nRows = region["row_out"]; const octave_idx_type nCols = region["col_out"]; T img; @@ -711,7 +711,7 @@ if (QuantumDepth < 32) warning_with_id ("Octave:GraphicsMagic-Quantum-Depth", - "your version of %s limits images to %d bits per pixel", + "your version of %s limits images to %d bits per pixel\n", MagickPackageName, QuantumDepth); initialized = true; @@ -776,7 +776,7 @@ } // Fix indexes from base 1 to base 0, and at the same time, make // sure none of the indexes is outside the range of image number. - const octave_idx_type n = frameidx.nelem (); + const octave_idx_type n = frameidx.numel (); for (octave_idx_type i = 0; i < n; i++) { frameidx(i)--; @@ -798,7 +798,7 @@ { const unsigned int nRows = imvec[frameidx(0)].rows (); const unsigned int nCols = imvec[frameidx(0)].columns (); - const octave_idx_type n = frameidx.nelem (); + const octave_idx_type n = frameidx.numel (); for (octave_idx_type frame = 0; frame < n; frame++) { if (nRows != imvec[frameidx(frame)].rows () diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/audiodevinfo.cc --- a/libinterp/dldfcn/audiodevinfo.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/audiodevinfo.cc Sat May 30 05:39:47 2015 -0400 @@ -1086,7 +1086,7 @@ unsigned int audioplayer::get_total_samples (void) { - return left.length (); + return left.numel (); } void @@ -1104,7 +1104,7 @@ void audioplayer::reset_end_sample (void) { - set_end_sample (left.length ()); + set_end_sample (left.numel ()); } void diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/audioread.cc --- a/libinterp/dldfcn/audioread.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/audioread.cc Sat May 30 05:39:47 2015 -0400 @@ -115,7 +115,7 @@ if (error_state) return retval; - if (range.nelem () != 2) + if (range.numel () != 2) { error ("audioread: invalid specification for range of frames"); return retval; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/ccolamd.cc --- a/libinterp/dldfcn/ccolamd.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/ccolamd.cc Sat May 30 05:39:47 2015 -0400 @@ -162,7 +162,7 @@ if (nargin > 1) { NDArray User_knobs = args(1).array_value (); - int nel_User_knobs = User_knobs.length (); + int nel_User_knobs = User_knobs.numel (); if (nel_User_knobs > 0) knobs[CCOLAMD_LU] = (User_knobs(0) != 0); @@ -273,7 +273,7 @@ if (nargin > 2) { NDArray in_cmember = args(2).array_value (); - octave_idx_type cslen = in_cmember.length (); + octave_idx_type cslen = in_cmember.numel (); OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen); for (octave_idx_type i = 0; i < cslen; i++) // convert cmember from 1-based to 0-based @@ -422,7 +422,7 @@ if (nargin > 1) { NDArray User_knobs = args(1).array_value (); - int nel_User_knobs = User_knobs.length (); + int nel_User_knobs = User_knobs.numel (); if (nel_User_knobs > 0) knobs[CCOLAMD_DENSE_ROW] = User_knobs(0); @@ -511,7 +511,7 @@ if (nargin > 2) { NDArray in_cmember = args(2).array_value (); - octave_idx_type cslen = in_cmember.length (); + octave_idx_type cslen = in_cmember.numel (); OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen); for (octave_idx_type i = 0; i < cslen; i++) // convert cmember from 1-based to 0-based diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/dldfcn/colamd.cc --- a/libinterp/dldfcn/colamd.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/dldfcn/colamd.cc Sat May 30 05:39:47 2015 -0400 @@ -297,7 +297,7 @@ if (nargin == 2) { NDArray User_knobs = args(1).array_value (); - int nel_User_knobs = User_knobs.length (); + int nel_User_knobs = User_knobs.numel (); if (nel_User_knobs > 0) knobs[COLAMD_DENSE_ROW] = User_knobs(0); @@ -534,7 +534,7 @@ if (nargin == 2) { NDArray User_knobs = args(1).array_value (); - int nel_User_knobs = User_knobs.length (); + int nel_User_knobs = User_knobs.numel (); if (nel_User_knobs > 0) knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-base-int.cc --- a/libinterp/octave-value/ov-base-int.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-base-int.cc Sat May 30 05:39:47 2015 -0400 @@ -129,7 +129,7 @@ { octave_base_value *retval = 0; - if (this->matrix.nelem () == 1) + if (this->matrix.numel () == 1) retval = new typename octave_value_int_traits::scalar_type (this->matrix (0)); @@ -193,7 +193,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i = 0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << this->matrix; @@ -355,7 +355,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-base-mat.cc --- a/libinterp/octave-value/ov-base-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-base-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -358,7 +358,7 @@ for (octave_idx_type i = 0; i < n_idx; i++) { j += idx_vec(i)(0) * k; - k *= dv (i); + k *= dv(i); } matrix(j) = rhs; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-base-sparse.cc --- a/libinterp/octave-value/ov-base-sparse.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-base-sparse.cc Sat May 30 05:39:47 2015 -0400 @@ -394,8 +394,8 @@ matrix.maybe_compress (); os << "# nnz: " << nnz () << "\n"; - os << "# rows: " << dv (0) << "\n"; - os << "# columns: " << dv (1) << "\n"; + os << "# rows: " << dv(0) << "\n"; + os << "# columns: " << dv(1) << "\n"; os << this->matrix; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-base-sparse.h --- a/libinterp/octave-value/ov-base-sparse.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-base-sparse.h Sat May 30 05:39:47 2015 -0400 @@ -143,7 +143,7 @@ bool is_true (void) const; - octave_idx_type capacity (void) const { return matrix.capacity (); } + GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); } bool print_as_scalar (void) const; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-base.h Sat May 30 05:39:47 2015 -0400 @@ -310,7 +310,8 @@ virtual octave_idx_type numel (void) const { return dims ().numel (); } - virtual octave_idx_type capacity (void) const { return numel (); } + GCC_ATTR_DEPRECATED virtual octave_idx_type capacity (void) const + { return numel (); } virtual size_t byte_size (void) const { return 0; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-bool-mat.cc --- a/libinterp/octave-value/ov-bool-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-bool-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -193,7 +193,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i = 0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << tmp; } @@ -252,7 +252,7 @@ if (is) { - for (octave_idx_type i = 0; i < btmp.nelem (); i++) + for (octave_idx_type i = 0; i < btmp.numel (); i++) btmp.elem (i) = (tmp.elem (i) != 0.); matrix = btmp; @@ -344,7 +344,7 @@ boolNDArray m = bool_array_value (); bool *mtmp = m.fortran_vec (); - octave_idx_type nel = m.nelem (); + octave_idx_type nel = m.numel (); OCTAVE_LOCAL_BUFFER (char, htmp, nel); for (octave_idx_type i = 0; i < nel; i++) @@ -431,7 +431,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; @@ -448,7 +448,7 @@ return false; } - octave_idx_type nel = m.nelem (); + octave_idx_type nel = m.numel (); bool *mtmp = m.fortran_vec (); OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nel); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-cell.cc --- a/libinterp/octave-value/ov-cell.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-cell.cc Sat May 30 05:39:47 2015 -0400 @@ -156,7 +156,7 @@ { Cell tcell = tmp.cell_value (); - if (tcell.length () == 1) + if (tcell.numel () == 1) retval(0) = tcell(0,0); else retval = octave_value (octave_value_list (tcell), true); @@ -208,7 +208,7 @@ { const Cell tcell = tmp.cell_value (); - if (tcell.length () == 1) + if (tcell.numel () == 1) retval = tcell(0,0); else retval = octave_value (octave_value_list (tcell), true); @@ -617,7 +617,7 @@ if (error_state) return retval; - octave_idx_type s_len = s.length (); + octave_idx_type s_len = s.numel (); n_elts += s_len ? s_len : 1; @@ -638,7 +638,7 @@ const string_vector s = strvec_queue.front (); strvec_queue.pop (); - octave_idx_type s_len = s.length (); + octave_idx_type s_len = s.numel (); if (s_len) { @@ -767,7 +767,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i = 0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n"; Cell tmp = cell_value (); @@ -1470,7 +1470,7 @@ // except if the struct is a column vector. dim_vector result_dv; - if (m_dv (m_dv.length () - 1) == 1) + if (m_dv(m_dv.length () - 1) == 1) result_dv.resize (m_dv.length ()); else result_dv.resize (m_dv.length () + 1); // Add 1 for the fields. diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-class.cc Sat May 30 05:39:47 2015 -0400 @@ -406,7 +406,7 @@ { Cell t = tmp.index (idx.front ()); - retval(0) = (t.length () == 1) ? t(0) + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell @@ -427,7 +427,7 @@ { Cell t = dotref (idx.front ()); - retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); } } break; @@ -508,7 +508,7 @@ { octave_value retval; - if (val.length () == 1) + if (val.numel () == 1) { retval = val(0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-class.h --- a/libinterp/octave-value/ov-class.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-class.h Sat May 30 05:39:47 2015 -0400 @@ -257,7 +257,7 @@ return *this; } - octave_idx_type nfields (void) const { return field_names.length (); } + octave_idx_type nfields (void) const { return field_names.numel (); } size_t nparents (void) const { return parent_class_names.size (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-classdef.cc Sat May 30 05:39:47 2015 -0400 @@ -1476,17 +1476,26 @@ case '(': { + const octave_value_list& ival = idx.front (); + refcount++; - cdef_object this_obj (this); - Array arr (dim_vector (1, 1), this_obj); - - cdef_object new_obj = cdef_object (new cdef_object_array (arr)); - - new_obj.set_class (get_class ()); - - retval = new_obj.subsref (type, idx, nargout, skip, cls, auto_add); + if (ival.empty ()) + { + skip++; + retval(0) = to_ov (this_obj); + } + else + { + Array arr (dim_vector (1, 1), this_obj); + + cdef_object new_obj = cdef_object (new cdef_object_array (arr)); + + new_obj.set_class (get_class ()); + + retval = new_obj.subsref (type, idx, nargout, skip, cls, auto_add); + } } break; @@ -1626,16 +1635,17 @@ case '(': { const octave_value_list& ival = idx.front (); - bool is_scalar = true; - Array iv (dim_vector (1, ival.length ())); if (ival.empty ()) { - ::error ("can't index %s object(s) with empty parentheses", - class_name ().c_str ()); + refcount++; + retval(0) = to_ov (cdef_object (this)); break; } + bool is_scalar = true; + Array iv (dim_vector (1, ival.length ())); + for (int i = 0; ! error_state && i < ival.length (); i++) { iv(i) = ival(i).index_vector (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-cx-mat.cc --- a/libinterp/octave-value/ov-cx-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-cx-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -337,7 +337,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i = 0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << tmp; } @@ -584,7 +584,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-fcn-inline.cc --- a/libinterp/octave-value/ov-fcn-inline.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-fcn-inline.cc Sat May 30 05:39:47 2015 -0400 @@ -70,7 +70,7 @@ buf << "@("; - for (int i = 0; i < ifargs.length (); i++) + for (int i = 0; i < ifargs.numel (); i++) { if (i > 0) buf << ", "; @@ -128,12 +128,12 @@ string_vector args = fcn_arg_names (); - m.assign ("numArgs", args.length ()); + m.assign ("numArgs", args.numel ()); m.assign ("args", args); std::ostringstream buf; - for (int i = 0; i < args.length (); i++) + for (int i = 0; i < args.numel (); i++) buf << args(i) << " = INLINE_INPUTS_{" << i + 1 << "}; "; m.assign ("inputExpr", buf.str ()); @@ -144,8 +144,8 @@ bool octave_fcn_inline::save_ascii (std::ostream& os) { - os << "# nargs: " << ifargs.length () << "\n"; - for (int i = 0; i < ifargs.length (); i++) + os << "# nargs: " << ifargs.numel () << "\n"; + for (int i = 0; i < ifargs.numel (); i++) os << ifargs(i) << "\n"; if (nm.length () < 1) // Write an invalid value to flag empty fcn handle name. @@ -195,9 +195,9 @@ bool octave_fcn_inline::save_binary (std::ostream& os, bool&) { - int32_t tmp = ifargs.length (); + int32_t tmp = ifargs.numel (); os.write (reinterpret_cast (&tmp), 4); - for (int i = 0; i < ifargs.length (); i++) + for (int i = 0; i < ifargs.numel (); i++) { tmp = ifargs(i).length (); os.write (reinterpret_cast (&tmp), 4); @@ -291,7 +291,7 @@ if (group_hid < 0) return false; size_t len = 0; - for (int i = 0; i < ifargs.length (); i++) + for (int i = 0; i < ifargs.numel (); i++) if (len < ifargs(i).length ()) len = ifargs(i).length (); @@ -304,7 +304,7 @@ OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2); // Octave uses column-major, while HDF5 uses row-major ordering - hdims[1] = ifargs.length (); + hdims[1] = ifargs.numel (); hdims[0] = len + 1; space_hid = H5Screate_simple (2, hdims, 0); @@ -327,10 +327,10 @@ return false; } - OCTAVE_LOCAL_BUFFER (char, s, ifargs.length () * (len + 1)); + OCTAVE_LOCAL_BUFFER (char, s, ifargs.numel () * (len + 1)); // Save the args as a null teminated list - for (int i = 0; i < ifargs.length (); i++) + for (int i = 0; i < ifargs.numel (); i++) { const char * cptr = ifargs(i).c_str (); for (size_t j = 0; j < ifargs(i).length (); j++) @@ -627,7 +627,7 @@ else buf << nm << "("; - for (int i = 0; i < ifargs.length (); i++) + for (int i = 0; i < ifargs.numel (); i++) { if (i) buf << ", "; @@ -751,7 +751,7 @@ { bool have_arg = false; - for (int j = 0; j < fargs.length (); j++) + for (int j = 0; j < fargs.numel (); j++) if (tmp_arg == fargs (j)) { have_arg = true; @@ -773,7 +773,7 @@ // Sort the arguments into ascii order. fargs.sort (); - if (fargs.length () == 0) + if (fargs.numel () == 0) fargs.append (std::string ("x")); } @@ -920,9 +920,9 @@ { string_vector t1 = fn->fcn_arg_names (); - Cell t2 (dim_vector (t1.length (), 1)); + Cell t2 (dim_vector (t1.numel (), 1)); - for (int i = 0; i < t1.length (); i++) + for (int i = 0; i < t1.numel (); i++) t2(i) = t1(i); retval = t2; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-flt-cx-mat.cc --- a/libinterp/octave-value/ov-flt-cx-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -311,7 +311,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i = 0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << tmp; } @@ -546,7 +546,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-flt-re-mat.cc --- a/libinterp/octave-value/ov-flt-re-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-flt-re-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -80,7 +80,7 @@ { octave_base_value *retval = 0; - if (matrix.nelem () == 1) + if (matrix.numel () == 1) retval = new octave_float_scalar (matrix (0)); return retval; @@ -338,7 +338,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i=0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << tmp; } @@ -573,7 +573,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-java.cc Sat May 30 05:39:47 2015 -0400 @@ -1097,7 +1097,7 @@ NDArray m (dims); mID = jni_env->GetMethodID (cls, "toDouble", "()[D"); jdoubleArray_ref dv (jni_env, reinterpret_cast (jni_env->CallObjectMethod (jobj, mID))); - jni_env->GetDoubleArrayRegion (dv, 0, m.length (), m.fortran_vec ()); + jni_env->GetDoubleArrayRegion (dv, 0, m.numel (), m.fortran_vec ()); retval = m; break; } @@ -1108,7 +1108,7 @@ uint8NDArray m (dims); mID = jni_env->GetMethodID (cls, "toByte", "()[B"); jbyteArray_ref dv (jni_env, reinterpret_cast (jni_env->CallObjectMethod (jobj, mID))); - jni_env->GetByteArrayRegion (dv, 0, m.length (), reinterpret_cast (m.fortran_vec ())); + jni_env->GetByteArrayRegion (dv, 0, m.numel (), reinterpret_cast (m.fortran_vec ())); retval = m; break; } @@ -1117,7 +1117,7 @@ int8NDArray m (dims); mID = jni_env->GetMethodID (cls, "toByte", "()[B"); jbyteArray_ref dv (jni_env, reinterpret_cast (jni_env->CallObjectMethod (jobj, mID))); - jni_env->GetByteArrayRegion (dv, 0, m.length (), reinterpret_cast (m.fortran_vec ())); + jni_env->GetByteArrayRegion (dv, 0, m.numel (), reinterpret_cast (m.fortran_vec ())); retval = m; break; } @@ -1129,7 +1129,7 @@ uint32NDArray m (dims); mID = jni_env->GetMethodID (cls, "toInt", "()[I"); jintArray_ref dv (jni_env, reinterpret_cast (jni_env->CallObjectMethod (jobj, mID))); - jni_env->GetIntArrayRegion (dv, 0, m.length (), reinterpret_cast (m.fortran_vec ())); + jni_env->GetIntArrayRegion (dv, 0, m.numel (), reinterpret_cast (m.fortran_vec ())); retval = m; break; } @@ -1138,7 +1138,7 @@ int32NDArray m (dims); mID = jni_env->GetMethodID (cls, "toInt", "()[I"); jintArray_ref dv (jni_env, reinterpret_cast (jni_env->CallObjectMethod (jobj, mID))); - jni_env->GetIntArrayRegion (dv, 0, m.length (), reinterpret_cast (m.fortran_vec ())); + jni_env->GetIntArrayRegion (dv, 0, m.numel (), reinterpret_cast (m.fortran_vec ())); retval = m; break; } @@ -1217,7 +1217,7 @@ jdoubleArray_ref row (jni_env, reinterpret_cast (jni_env->GetObjectArrayElement (jarr, r))); - if (m.length () == 0) + if (m.numel () == 0) { cols = jni_env->GetArrayLength (row); m.resize (cols, rows); @@ -1348,8 +1348,8 @@ || val.is_range ())) { Matrix m = val.matrix_value (); - jdoubleArray dv = jni_env->NewDoubleArray (m.length ()); - jni_env->SetDoubleArrayRegion (dv, 0, m.length (), m.fortran_vec ()); + jdoubleArray dv = jni_env->NewDoubleArray (m.numel ()); + jni_env->SetDoubleArrayRegion (dv, 0, m.numel (), m.fortran_vec ()); jobj = dv; jcls = jni_env->GetObjectClass (jobj); } @@ -1369,8 +1369,8 @@ if (val.is_double_type ()) { NDArray m = val.array_value (); - jdoubleArray_ref dv (jni_env, jni_env->NewDoubleArray (m.length ())); - jni_env->SetDoubleArrayRegion (jdoubleArray (dv), 0, m.length (), + jdoubleArray_ref dv (jni_env, jni_env->NewDoubleArray (m.numel ())); + jni_env->SetDoubleArrayRegion (jdoubleArray (dv), 0, m.numel (), m.fortran_vec ()); jmethodID mID = jni_env->GetMethodID (mcls, "", "([D[I)V"); jobj = jni_env->NewObject (jclass (mcls), mID, jdoubleArray (dv), @@ -1380,8 +1380,8 @@ else if (val.is_int8_type ()) { int8NDArray m = val.int8_array_value (); - jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.length ())); - jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.length (), + jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ())); + jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (), reinterpret_cast (m.fortran_vec ())); jmethodID mID = jni_env->GetMethodID (mcls, "", "([B[I)V"); jobj = jni_env->NewObject (jclass (mcls), mID, jbyteArray (bv), jintArray (iv)); @@ -1390,8 +1390,8 @@ else if (val.is_uint8_type ()) { uint8NDArray m = val.uint8_array_value (); - jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.length ())); - jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.length (), + jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ())); + jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (), reinterpret_cast (m.fortran_vec ())); jmethodID mID = jni_env->GetMethodID (mcls, "", "([B[I)V"); jobj = jni_env->NewObject (jclass (mcls), mID, jbyteArray (bv), jintArray (iv)); @@ -1400,8 +1400,8 @@ else if (val.is_int32_type ()) { int32NDArray m = val.int32_array_value (); - jintArray_ref v (jni_env, jni_env->NewIntArray (m.length ())); - jni_env->SetIntArrayRegion (jintArray (v), 0, m.length (), + jintArray_ref v (jni_env, jni_env->NewIntArray (m.numel ())); + jni_env->SetIntArrayRegion (jintArray (v), 0, m.numel (), reinterpret_cast (m.fortran_vec ())); jmethodID mID = jni_env->GetMethodID (mcls, "", "([I[I)V"); jobj = jni_env->NewObject (jclass (mcls), mID, jintArray (v), jintArray (iv)); @@ -1417,8 +1417,8 @@ { Cell cellStr = val.cell_value (); jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String")); - jobjectArray array = jni_env->NewObjectArray (cellStr.length (), scls, 0); - for (int i = 0; i < cellStr.length (); i++) + jobjectArray array = jni_env->NewObjectArray (cellStr.numel (), scls, 0); + for (int i = 0; i < cellStr.numel (); i++) { jstring_ref jstr (jni_env, jni_env->NewStringUTF (cellStr(i).string_value().c_str ())); @@ -1602,7 +1602,7 @@ Cell c = val.cell_value (); octave_function *fcn = c(0).function_value (); - for (int i=1; i= 0 && dim <= 1) && odims (1-dim) == 1) + && (dim >= 0 && dim <= 1) && odims(1-dim) == 1) return index_vector ().sorted (); else return idx_vector (index.as_array ().sort (dim, mode), @@ -120,7 +120,7 @@ const dim_vector odims = index.orig_dimensions (); // index_vector can employ a more efficient sorting algorithm. if (mode == ASCENDING && odims.length () == 2 - && (dim >= 0 && dim <= 1) && odims (1-dim) == 1) + && (dim >= 0 && dim <= 1) && odims(1-dim) == 1) return index_vector ().sorted (sidx); else return idx_vector (index.as_array ().sort (sidx, dim, mode), diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-perm.cc --- a/libinterp/octave-value/ov-perm.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-perm.cc Sat May 30 05:39:47 2015 -0400 @@ -261,7 +261,7 @@ os << "# orient: c\n"; Array pvec = matrix.col_perm_vec (); - octave_idx_type n = pvec.length (); + octave_idx_type n = pvec.numel (); ColumnVector tmp (n); for (octave_idx_type i = 0; i < n; i++) tmp(i) = pvec(i) + 1; os << tmp; @@ -439,7 +439,7 @@ { octave_base_value *retval = 0; - if (matrix.nelem () == 1) + if (matrix.numel () == 1) retval = new octave_scalar (matrix (0, 0)); return retval; diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-range.cc --- a/libinterp/octave-value/ov-range.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-range.cc Sat May 30 05:39:47 2015 -0400 @@ -72,7 +72,7 @@ { octave_base_value *retval = 0; - switch (range.nelem ()) + switch (range.numel ()) { case 1: retval = new octave_scalar (range.base ()); @@ -131,7 +131,7 @@ idx_vector i = idx(0).index_vector (); if (! error_state) { - if (i.is_scalar () && i(0) < range.nelem ()) + if (i.is_scalar () && i(0) < range.numel ()) retval = range.elem (i(0)); else retval = range.index (i); @@ -173,7 +173,7 @@ { double retval = lo_ieee_nan_value (); - octave_idx_type nel = range.nelem (); + octave_idx_type nel = range.numel (); if (nel > 0) { @@ -193,7 +193,7 @@ { float retval = lo_ieee_float_nan_value (); - octave_idx_type nel = range.nelem (); + octave_idx_type nel = range.numel (); if (nel > 0) { @@ -264,7 +264,7 @@ { bool retval = false; - if (range.nelem () != 0) + if (range.numel () != 0) { // FIXME: this is a potential waste of memory. @@ -283,7 +283,7 @@ Complex retval (tmp, tmp); - octave_idx_type nel = range.nelem (); + octave_idx_type nel = range.numel (); if (nel > 0) { @@ -305,7 +305,7 @@ FloatComplex retval (tmp, tmp); - octave_idx_type nel = range.nelem (); + octave_idx_type nel = range.numel (); if (nel > 0) { @@ -370,7 +370,7 @@ { bool retval = false; - octave_idx_type n = range.nelem (); + octave_idx_type n = range.numel (); indent (os); @@ -392,7 +392,7 @@ void octave_range::short_disp (std::ostream& os) const { - octave_idx_type len = range.nelem (); + octave_idx_type len = range.numel (); if (len == 0) os << "[]"; @@ -434,7 +434,7 @@ double base = r.base (); double limit = r.limit (); double inc = r.inc (); - octave_idx_type len = r.nelem (); + octave_idx_type len = r.numel (); if (inc != 0) os << "# base, limit, increment\n"; @@ -487,7 +487,7 @@ double lim = r.limit (); double inc = r.inc (); if (inc == 0) - lim = r.nelem (); + lim = r.numel (); os.write (reinterpret_cast (&bas), 8); os.write (reinterpret_cast (&lim), 8); @@ -583,13 +583,13 @@ Range r = range_value (); double range_vals[3]; range_vals[0] = r.base (); - range_vals[1] = r.inc () != 0 ? r.limit () : r.nelem (); + range_vals[1] = r.inc () != 0 ? r.limit () : r.numel (); range_vals[2] = r.inc (); if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, range_vals) >= 0) { - octave_idx_type nel = r.nelem (); + octave_idx_type nel = r.numel (); retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX, "OCTAVE_RANGE_NELEM", &nel) >= 0; } @@ -693,7 +693,7 @@ octave_value octave_range::fast_elem_extract (octave_idx_type n) const { - return (n < range.nelem ()) ? octave_value (range.elem (n)) + return (n < range.numel ()) ? octave_value (range.elem (n)) : octave_value (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-range.h --- a/libinterp/octave-value/ov-range.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-range.h Sat May 30 05:39:47 2015 -0400 @@ -58,14 +58,14 @@ octave_range (double base, double limit, double inc) : octave_base_value (), range (base, limit, inc), idx_cache () { - if (range.nelem () < 0) + if (range.numel () < 0) ::error ("invalid range"); } octave_range (const Range& r) : octave_base_value (), range (r), idx_cache () { - if (range.nelem () < 0 && range.nelem () != -2) + if (range.numel () < 0 && range.numel () != -2) ::error ("invalid range"); } @@ -107,7 +107,7 @@ dim_vector dims (void) const { - octave_idx_type n = range.nelem (); + octave_idx_type n = range.numel (); return dim_vector (n > 0, n); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-re-mat.cc --- a/libinterp/octave-value/ov-re-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-re-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -95,7 +95,7 @@ { octave_base_value *retval = 0; - if (matrix.nelem () == 1) + if (matrix.numel () == 1) retval = new octave_scalar (matrix (0)); return retval; @@ -440,7 +440,7 @@ os << "# ndims: " << d.length () << "\n"; for (int i=0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n" << tmp; } @@ -685,7 +685,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-str-mat.cc --- a/libinterp/octave-value/ov-str-mat.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-str-mat.cc Sat May 30 05:39:47 2015 -0400 @@ -292,7 +292,7 @@ charNDArray tmp = char_array_value (); os << "# ndims: " << d.length () << "\n"; for (int i=0; i < d.length (); i++) - os << " " << d (i); + os << " " << d(i); os << "\n"; os.write (tmp.fortran_vec (), d.numel ()); os << "\n"; @@ -592,7 +592,7 @@ // Octave uses column-major, while HDF5 uses row-major ordering for (int i = 0; i < rank; i++) - hdims[i] = dv (rank-i-1); + hdims[i] = dv(rank-i-1); space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-struct.cc --- a/libinterp/octave-value/ov-struct.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-struct.cc Sat May 30 05:39:47 2015 -0400 @@ -157,7 +157,7 @@ { const Cell t = tmp.index (idx.front ()); - retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell // next_subsref to skip both of them. @@ -176,7 +176,7 @@ { const Cell t = dotref (idx.front ()); - retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); + retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true); } } break; @@ -223,7 +223,7 @@ { const Cell t = tmp.index (idx.front (), auto_add); - retval = (t.length () == 1) ? t(0) : octave_value (t, true); + retval = (t.numel () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell // next_subsref to skip both of them. @@ -242,7 +242,7 @@ { const Cell t = dotref (idx.front (), auto_add); - retval = (t.length () == 1) ? t(0) : octave_value (t, true); + retval = (t.numel () == 1) ? t(0) : octave_value (t, true); } } break; @@ -679,7 +679,7 @@ string_vector key_list = map.fieldnames (); - for (octave_idx_type i = 0; i < key_list.length (); i++) + for (octave_idx_type i = 0; i < key_list.numel (); i++) { std::string key = key_list[i]; @@ -735,7 +735,7 @@ static bool scalar (const dim_vector& dims) { - return dims.length () == 2 && dims (0) == 1 && dims (1) == 1; + return dims.length () == 2 && dims(0) == 1 && dims(1) == 1; } @@ -751,7 +751,7 @@ os << "# ndims: " << dv.length () << "\n"; for (int i = 0; i < dv.length (); i++) - os << " " << dv (i); + os << " " << dv(i); os << "\n"; os << "# length: " << nf << "\n"; @@ -1400,7 +1400,7 @@ string_vector key_list = map.fieldnames (); - for (octave_idx_type i = 0; i < key_list.length (); i++) + for (octave_idx_type i = 0; i < key_list.numel (); i++) { std::string key = key_list[i]; @@ -1461,7 +1461,7 @@ os << "# ndims: " << dv.length () << "\n"; for (int i = 0; i < dv.length (); i++) - os << " " << dv (i); + os << " " << dv(i); os << "\n"; os << "# length: " << nf << "\n"; @@ -2017,7 +2017,7 @@ string_vector keys = m.fieldnames (); - if (keys.length () == 0) + if (keys.numel () == 0) retval = Cell (0, 1); else retval = Cell (keys); diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov-typeinfo.cc --- a/libinterp/octave-value/ov-typeinfo.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov-typeinfo.cc Sat May 30 05:39:47 2015 -0400 @@ -193,7 +193,7 @@ if (t_name == types (i)) return i; - int len = types.length (); + int len = types.numel (); if (i == len) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov.cc --- a/libinterp/octave-value/ov.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov.cc Sat May 30 05:39:47 2015 -0400 @@ -2998,7 +2998,7 @@ { Cell subs_cell = subs(k).cell_value (); - for (int n = 0; n < subs_cell.length (); n++) + for (int n = 0; n < subs_cell.numel (); n++) { if (subs_cell(n).is_string () && subs_cell(n).string_value () == ":") diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/octave-value/ov.h Sat May 30 05:39:47 2015 -0400 @@ -483,8 +483,8 @@ octave_idx_type numel (void) const { return rep->numel (); } - octave_idx_type capacity (void) const - { return rep->capacity (); } + GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const + { return rep->numel (); } size_t byte_size (void) const { return rep->byte_size (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/operators/op-int.h --- a/libinterp/operators/op-int.h Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/operators/op-int.h Sat May 30 05:39:47 2015 -0400 @@ -370,7 +370,7 @@ elem_xpow (const octave_ ## T1& a, const T2 ## NDArray& b) \ { \ T2 ## NDArray result (b.dims ()); \ - for (int i = 0; i < b.length (); i++) \ + for (int i = 0; i < b.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a, b(i)); \ @@ -382,7 +382,7 @@ elem_xpow (const octave_ ## T1& a, const NDArray& b) \ { \ T1 ## NDArray result (b.dims ()); \ - for (int i = 0; i < b.length (); i++) \ + for (int i = 0; i < b.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a, b(i)); \ @@ -394,7 +394,7 @@ elem_xpow (double a, const T2 ## NDArray& b) \ { \ T2 ## NDArray result (b.dims ()); \ - for (int i = 0; i < b.length (); i++) \ + for (int i = 0; i < b.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a, b(i)); \ @@ -406,7 +406,7 @@ elem_xpow (const octave_ ## T1& a, const FloatNDArray& b) \ { \ T1 ## NDArray result (b.dims ()); \ - for (int i = 0; i < b.length (); i++) \ + for (int i = 0; i < b.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a, b(i)); \ @@ -418,7 +418,7 @@ elem_xpow (float a, const T2 ## NDArray& b) \ { \ T2 ## NDArray result (b.dims ()); \ - for (int i = 0; i < b.length (); i++) \ + for (int i = 0; i < b.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a, b(i)); \ @@ -536,7 +536,7 @@ octave_value elem_xpow (T1 ## NDArray a, octave_ ## T2 b) \ { \ T1 ## NDArray result (a.dims ()); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b); \ @@ -547,7 +547,7 @@ octave_value elem_xpow (T1 ## NDArray a, double b) \ { \ T1 ## NDArray result (a.dims ()); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b); \ @@ -558,7 +558,7 @@ octave_value elem_xpow (NDArray a, octave_ ## T2 b) \ { \ T2 ## NDArray result (a.dims ()); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b); \ @@ -569,7 +569,7 @@ octave_value elem_xpow (T1 ## NDArray a, float b) \ { \ T1 ## NDArray result (a.dims ()); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a(i), b); \ @@ -580,7 +580,7 @@ octave_value elem_xpow (FloatNDArray a, octave_ ## T2 b) \ { \ T2 ## NDArray result (a.dims ()); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a(i), b); \ @@ -715,7 +715,7 @@ } \ } \ T1 ## NDArray result (a_dims); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b(i)); \ @@ -741,7 +741,7 @@ } \ } \ T1 ## NDArray result (a_dims); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b(i)); \ @@ -767,7 +767,7 @@ } \ } \ T2 ## NDArray result (a_dims); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = pow (a(i), b(i)); \ @@ -793,7 +793,7 @@ } \ } \ T1 ## NDArray result (a_dims); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a(i), b(i)); \ @@ -819,7 +819,7 @@ } \ } \ T2 ## NDArray result (a_dims); \ - for (int i = 0; i < a.length (); i++) \ + for (int i = 0; i < a.numel (); i++) \ { \ OCTAVE_QUIT; \ result (i) = powf (a(i), b(i)); \ diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Sat May 30 05:39:47 2015 -0400 @@ -337,7 +337,7 @@ { Range rng = rhs.range_value (); - octave_idx_type steps = rng.nelem (); + octave_idx_type steps = rng.numel (); for (octave_idx_type i = 0; i < steps; i++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 libinterp/parse-tree/pt-pr-code.cc --- a/libinterp/parse-tree/pt-pr-code.cc Sat May 23 10:35:40 2015 -0400 +++ b/libinterp/parse-tree/pt-pr-code.cc Sat May 30 05:39:47 2015 -0400 @@ -329,7 +329,7 @@ cmd_list->accept (*this); - decrement_indent_level (); + // endfunction will decrement the indent level. } visit_octave_user_function_trailer (fcn); @@ -600,7 +600,7 @@ case '.': { string_vector nm = *p_arg_names; - assert (nm.length () == 1); + assert (nm.numel () == 1); os << "." << nm(0); } break; @@ -719,6 +719,9 @@ void tree_print_code::visit_no_op_command (tree_no_op_command& cmd) { + if (cmd.is_end_of_fcn_or_script ()) + decrement_indent_level (); + indent (); os << cmd.original_command (); @@ -873,13 +876,7 @@ { cmd->accept (*this); - if (! stmt.print_result ()) - { - os << ";"; - newline (" "); - } - else - newline (); + newline (); } else { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Array-util.cc --- a/liboctave/array/Array-util.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Array-util.cc Sat May 30 05:39:47 2015 -0400 @@ -36,7 +36,7 @@ { bool retval = true; - int n = ra_idx.length (); + int n = ra_idx.numel (); if (n == dimensions.length ()) { @@ -61,7 +61,7 @@ { ra_idx(start_dimension)++; - int n = ra_idx.length () - 1; + int n = ra_idx.numel () - 1; int nda = dimensions.length (); for (int i = start_dimension; i < n; i++) @@ -81,7 +81,7 @@ { octave_idx_type retval (-1); - int n = idx.length (); + int n = idx.numel (); if (n > 0) { @@ -89,7 +89,7 @@ while (--n >= 0) { - retval *= dims (n); + retval *= dims(n); retval += idx(n); } @@ -102,9 +102,9 @@ { octave_idx_type retval = 0; - for (octave_idx_type i = 0; i < ra_idx.length (); i++) + for (octave_idx_type i = 0; i < ra_idx.numel (); i++) { - if (ra_idx (i) == 1) + if (ra_idx(i) == 1) retval++; } @@ -126,7 +126,7 @@ { for (int i = 0; i < n; i ++) { - if (dim (i) != 1) + if (dim(i) != 1) { retval = false; @@ -148,7 +148,7 @@ else { for (int i = 0; i < n; i ++) - if (dim (i) > 1) + if (dim(i) > 1) m++; else if (dim(i) < 1) m += 2; @@ -162,7 +162,7 @@ { bool retval = false; - for (octave_idx_type i = 0; i < arr.length (); i++) + for (octave_idx_type i = 0; i < arr.numel (); i++) { if (arr (i) == 1) { @@ -217,7 +217,7 @@ octave_idx_type compute_index (const Array& ra_idx, const dim_vector& dims) { - int nd = ra_idx.length (); + int nd = ra_idx.numel (); const dim_vector dv = dims.redim (nd); for (int d = 0; d < nd; d++) { @@ -235,7 +235,7 @@ { Array retval (a.dims ()); - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) retval(i) = a(i).elem (0); return retval; @@ -257,7 +257,7 @@ { dim_vector retval; - int n = ra_idx.length (); + int n = ra_idx.numel (); assert (n == dimensions.length ()); @@ -298,7 +298,7 @@ { bool retval = true; - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -317,7 +317,7 @@ { bool retval = false; - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); for (octave_idx_type i = 0; i < n; i++) { @@ -337,7 +337,7 @@ { bool retval = true; - octave_idx_type idx_n = ra_idx.length (); + octave_idx_type idx_n = ra_idx.numel (); int n = frozen_lengths.length (); @@ -360,7 +360,7 @@ { bool retval = true; - for (octave_idx_type i = 0; i < arr.length (); i++) + for (octave_idx_type i = 0; i < arr.numel (); i++) { if (arr(i) != 1) { @@ -376,7 +376,7 @@ get_elt_idx (const Array& ra_idx, const Array& result_idx) { - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); Array retval (dim_vector (n, 1)); @@ -423,7 +423,7 @@ dim_vector zero_dims_inquire (const Array& ia, const dim_vector& rhdv) { - int ial = ia.length (); + int ial = ia.numel (); int rhdvl = rhdv.length (); dim_vector rdv = dim_vector::alloc (ial); bool *scalar = new bool [ial]; @@ -530,7 +530,7 @@ sub2ind (const dim_vector& dv, const Array& idxa) { idx_vector retval; - octave_idx_type len = idxa.length (); + octave_idx_type len = idxa.numel (); if (len >= 1) { @@ -560,7 +560,7 @@ // All scalars case - the result is a scalar. octave_idx_type idx = idxa(len-1)(0); for (octave_idx_type i = len - 2; i >= 0; i--) - idx = idx * dvx(i) + idxa(i)(0); + idx = dvx(i) * idx + idxa(i)(0); retval = idx_vector (idx); } else if (all_ranges && clen != 0) @@ -572,8 +572,8 @@ { octave_idx_type xstart = idxa(i)(0); octave_idx_type xstep = idxa(i)(1) - xstart; - start = start * dvx(i) + xstart; - step = step * dvx(i) + xstep; + start = dvx(i) * start + xstart; + step = dvx(i) * step + xstep; } retval = idx_vector::make_range (start, step, clen); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Array.cc --- a/liboctave/array/Array.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Array.cc Sat May 30 05:39:47 2015 -0400 @@ -72,7 +72,7 @@ if (rep->count > 1) { --rep->count; - rep = new ArrayRep (length (), val); + rep = new ArrayRep (numel (), val); slice_data = rep->data; } else @@ -313,7 +313,7 @@ : n (dv.length ()), top (0), dim (new octave_idx_type [2*n]), stride (dim + n), use_blk (false) { - assert (n == perm.length ()); + assert (n == perm.numel ()); // Get cumulative dimensions. OCTAVE_LOCAL_BUFFER (octave_idx_type, cdim, n+1); @@ -446,7 +446,7 @@ dim_vector dv = dims (); - int perm_vec_len = perm_vec_arg.length (); + int perm_vec_len = perm_vec_arg.numel (); if (perm_vec_len < dv.length ()) (*current_liboctave_error_handler) @@ -532,7 +532,7 @@ public: rec_index_helper (const dim_vector& dv, const Array& ia) - : n (ia.length ()), top (0), dim (new octave_idx_type [2*n]), + : n (ia.numel ()), top (0), dim (new octave_idx_type [2*n]), cdim (dim + n), idx (new idx_vector [n]) { assert (n > 0 && (dv.length () == std::max (n, 2))); @@ -837,7 +837,7 @@ Array Array::index (const Array& ia) const { - int ial = ia.length (); + int ial = ia.numel (); Array retval; // FIXME: is this dispatching necessary? @@ -1112,10 +1112,10 @@ Array tmp = *this; if (resize_ok) { - int ial = ia.length (); + int ial = ia.numel (); dim_vector dv = dimensions.redim (ial); dim_vector dvx = dim_vector::alloc (ial); - for (int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv (i)); + for (int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv(i)); if (! (dvx == dv)) { bool all_scalars = true; @@ -1290,7 +1290,7 @@ Array::assign (const Array& ia, const Array& rhs, const T& rfv) { - int ial = ia.length (); + int ial = ia.numel (); // FIXME: is this dispatching necessary / desirable? if (ial == 1) @@ -1439,7 +1439,7 @@ return; } - octave_idx_type n = dimensions (dim); + octave_idx_type n = dimensions(dim); if (i.is_colon ()) { *this = Array (); @@ -1492,7 +1492,7 @@ void Array::delete_elements (const Array& ia) { - int ial = ia.length (); + int ial = ia.numel (); if (ial == 1) delete_elements (ia(0)); @@ -1590,11 +1590,11 @@ Array& Array::insert (const Array& a, const Array& ra_idx) { - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); Array idx (dim_vector (n, 1)); const dim_vector dva = a.dims ().redim (n); for (octave_idx_type k = 0; k < n; k++) - idx(k) = idx_vector (ra_idx (k), ra_idx (k) + dva(k)); + idx(k) = idx_vector (ra_idx(k), ra_idx(k) + dva(k)); assign (idx, a); @@ -1776,7 +1776,7 @@ dim_vector dv = m.dims (); - if (m.length () < 1) + if (m.numel () < 1) return m; if (dim >= dv.length ()) @@ -1897,7 +1897,7 @@ dim_vector dv = m.dims (); - if (m.length () < 1) + if (m.numel () < 1) { sidx = Array (dv); return m; @@ -2231,7 +2231,7 @@ Array::nnz (void) const { const T *src = data (); - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); octave_idx_type retval = 0; const T zero = T (); for (octave_idx_type i = 0; i < nel; i++) @@ -2247,7 +2247,7 @@ { Array retval; const T *src = data (); - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); const T zero = T (); if (n < 0 || n >= nel) { @@ -2317,7 +2317,7 @@ || (rows () == 0 && dims ().numel (1) == 0)) retval.dimensions = dim_vector (); else if (rows () == 1 && ndims () == 2) - retval.dimensions = dim_vector (1, retval.length ()); + retval.dimensions = dim_vector (1, retval.numel ()); return retval; } @@ -2533,8 +2533,8 @@ (*current_liboctave_error_handler) ("Matrix must be 2-dimensional"); else { - octave_idx_type nnr = dv (0); - octave_idx_type nnc = dv (1); + octave_idx_type nnr = dv(0); + octave_idx_type nnc = dv(1); if (nnr == 0 && nnc == 0) ; // do nothing for empty matrix diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Array.h --- a/liboctave/array/Array.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Array.h Sat May 30 05:39:47 2015 -0400 @@ -88,7 +88,7 @@ ~ArrayRep (void) { delete [] data; } - octave_idx_type length (void) const { return len; } + octave_idx_type numel (void) const { return len; } private: @@ -203,7 +203,7 @@ template Array (const Array& a) : dimensions (a.dims ()), - rep (new typename Array::ArrayRep (a.data (), a.length ())), + rep (new typename Array::ArrayRep (a.data (), a.numel ())), slice_data (rep->data), slice_len (rep->len) { } @@ -252,11 +252,13 @@ // Number of elements in the array. These are all synonyms. //@{ //! Number of elements in the array. - //! Synonymous with length(), nelem(), and numel(). - octave_idx_type capacity (void) const { return slice_len; } + //! Synonymous with numel(). + //! @note This method is deprecated in favour of numel(). + GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return numel (); } //! Number of elements in the array. - /*! Synonymous with capacity(), nelem(), and numel(). + /*! Synonymous with numel(). + @note This method is deprecated in favour of numel(). @note This is @em not the same as @c %length() at the Octave interpreter. @@ -264,15 +266,15 @@ length of the greatest dimension. This method returns the total number of elements. */ - octave_idx_type length (void) const { return capacity (); } + GCC_ATTR_DEPRECATED octave_idx_type length (void) const { return numel (); } //! Number of elements in the array. - //! Synonymous with capacity(), length(), and numel(). - octave_idx_type nelem (void) const { return capacity (); } + //! Synonymous with numel(). + //! @note This method is deprecated in favour of numel(). + GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); } //! Number of elements in the array. - //! Synonymous with capacity(), length(), and nelem(). - octave_idx_type numel (void) const { return nelem (); } + octave_idx_type numel (void) const { return slice_len; } //@} //! Return the array as a column vector. @@ -346,7 +348,7 @@ octave_idx_type compute_index_unchecked (const Array& ra_idx) const - { return dimensions.compute_index (ra_idx.data (), ra_idx.length ()); } + { return dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); } // No checking, even for multiple references, ever. @@ -658,7 +660,7 @@ Array map (F fcn) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); const T *m = data (); @@ -701,7 +703,7 @@ template bool test (F fcn) const { - return any_all_test (fcn, data (), length ()); + return any_all_test (fcn, data (), numel ()); } //@{ diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/CColVector.cc --- a/liboctave/array/CColVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/CColVector.cc Sat May 30 05:39:47 2015 -0400 @@ -60,8 +60,8 @@ bool ComplexColumnVector::operator == (const ComplexColumnVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -77,9 +77,9 @@ ComplexColumnVector& ComplexColumnVector::insert (const ColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -99,9 +99,9 @@ ComplexColumnVector& ComplexColumnVector::insert (const ComplexColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -121,7 +121,7 @@ ComplexColumnVector& ComplexColumnVector::fill (double val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -137,7 +137,7 @@ ComplexColumnVector& ComplexColumnVector::fill (const Complex& val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -154,7 +154,7 @@ ComplexColumnVector& ComplexColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -179,7 +179,7 @@ ComplexColumnVector::fill (const Complex& val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -203,9 +203,9 @@ ComplexColumnVector ComplexColumnVector::stack (const ColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - ComplexColumnVector retval (len + a.length ()); + ComplexColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -214,9 +214,9 @@ ComplexColumnVector ComplexColumnVector::stack (const ComplexColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - ComplexColumnVector retval (len + a.length ()); + ComplexColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -279,9 +279,9 @@ ComplexColumnVector& ComplexColumnVector::operator += (const ColumnVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -301,9 +301,9 @@ ComplexColumnVector& ComplexColumnVector::operator -= (const ColumnVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -337,7 +337,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -382,7 +382,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -410,7 +410,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -438,7 +438,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -465,7 +465,7 @@ Complex ComplexColumnVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -485,7 +485,7 @@ Complex ComplexColumnVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -508,7 +508,7 @@ operator << (std::ostream& os, const ComplexColumnVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << /* setw (field_width) << */ a.elem (i) << "\n"; return os; } @@ -516,7 +516,7 @@ std::istream& operator >> (std::istream& is, ComplexColumnVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/CDiagMatrix.cc --- a/liboctave/array/CDiagMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/CDiagMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -110,7 +110,7 @@ ComplexDiagMatrix::fill (const ColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -126,7 +126,7 @@ ComplexDiagMatrix::fill (const ComplexColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -142,7 +142,7 @@ ComplexDiagMatrix::fill (const RowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -158,7 +158,7 @@ ComplexDiagMatrix::fill (const ComplexRowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -173,7 +173,7 @@ ComplexDiagMatrix& ComplexDiagMatrix::fill (const ColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -189,7 +189,7 @@ ComplexDiagMatrix& ComplexDiagMatrix::fill (const ComplexColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -205,7 +205,7 @@ ComplexDiagMatrix& ComplexDiagMatrix::fill (const RowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -221,7 +221,7 @@ ComplexDiagMatrix& ComplexDiagMatrix::fill (const ComplexRowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/CMatrix.cc --- a/liboctave/array/CMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/CMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -366,7 +366,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return false; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool @@ -423,7 +423,7 @@ ComplexMatrix& ComplexMatrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { @@ -446,7 +446,7 @@ ComplexMatrix::insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -505,7 +505,7 @@ ComplexMatrix::insert (const ComplexRowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { (*current_liboctave_error_handler) ("range error for insert"); @@ -522,7 +522,7 @@ ComplexMatrix::insert (const ComplexColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -693,7 +693,7 @@ } octave_idx_type nc_insert = nc; - ComplexMatrix retval (nr, nc + a.length ()); + ComplexMatrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -704,7 +704,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return *this; @@ -765,7 +765,7 @@ } octave_idx_type nc_insert = nc; - ComplexMatrix retval (nr, nc + a.length ()); + ComplexMatrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -776,7 +776,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return *this; @@ -831,7 +831,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -858,7 +858,7 @@ } octave_idx_type nr_insert = nr; - ComplexMatrix retval (nr + a.length (), nc); + ComplexMatrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -907,7 +907,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -934,7 +934,7 @@ } octave_idx_type nr_insert = nr; - ComplexMatrix retval (nr + a.length (), nc); + ComplexMatrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -1229,7 +1229,7 @@ ColumnVector sigma = S.extract_diag (); - octave_idx_type r = sigma.length () - 1; + octave_idx_type r = sigma.numel () - 1; octave_idx_type nr = rows (); octave_idx_type nc = cols (); @@ -1320,7 +1320,7 @@ ComplexMatrix ComplexMatrix::fourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); ComplexMatrix retval (rows (), cols ()); const Complex *in (data ()); @@ -1334,7 +1334,7 @@ ComplexMatrix ComplexMatrix::ifourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); ComplexMatrix retval (rows (), cols ()); const Complex *in (data ()); @@ -2844,7 +2844,7 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m != b.length ()) + if (m != b.numel ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); else if (m == 0 || n == 0 || b.cols () == 0) @@ -2957,11 +2957,11 @@ { ComplexMatrix retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); if (len != 0) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); retval = ComplexMatrix (len, a_len); Complex *c = retval.fortran_vec (); @@ -3085,7 +3085,7 @@ Complex *d = fortran_vec (); // Ensures only one reference to my privates! - mx_inline_add2 (length (), d, a.data ()); + mx_inline_add2 (numel (), d, a.data ()); return *this; } @@ -3109,7 +3109,7 @@ Complex *d = fortran_vec (); // Ensures only one reference to my privates! - mx_inline_sub2 (length (), d, a.data ()); + mx_inline_sub2 (numel (), d, a.data ()); return *this; } @@ -4001,9 +4001,9 @@ { if (n < 1) n = 1; - octave_idx_type m = x1.length (); - - if (x2.length () != m) + octave_idx_type m = x1.numel (); + + if (x2.numel () != m) (*current_liboctave_error_handler) ("linspace: vectors must be of equal length"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/CNDArray.cc --- a/liboctave/array/CNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/CNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -69,9 +69,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const Complex *in (fortran_vec ()); @@ -100,9 +100,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const Complex *in (fortran_vec ()); @@ -124,7 +124,7 @@ if (dv.length () < 2) return ComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const Complex *in = fortran_vec (); ComplexNDArray retval (dv); Complex *out = retval.fortran_vec (); @@ -144,7 +144,7 @@ if (dv.length () < 2) return ComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const Complex *in = fortran_vec (); ComplexNDArray retval (dv); Complex *out = retval.fortran_vec (); @@ -535,7 +535,7 @@ bool ComplexNDArray::all_integers (double& max_val, double& min_val) const { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); if (nel > 0) { @@ -765,7 +765,7 @@ for (int i = 0; i < n; i++) { - if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i)) + if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i)) { (*current_liboctave_error_handler) ("Array::insert: range error for insert"); @@ -778,14 +778,14 @@ octave_idx_type n_elt = a.numel (); - // IS make_unique () NECCESSARY HERE?? + // IS make_unique () NECESSARY HERE? for (octave_idx_type i = 0; i < n_elt; i++) { Array ra_idx = a_ra_idx; - ra_idx.elem (0) = a_ra_idx (0) + r; - ra_idx.elem (1) = a_ra_idx (1) + c; + ra_idx.elem (0) = a_ra_idx(0) + r; + ra_idx.elem (1) = a_ra_idx(1) + c; elem (ra_idx) = a.elem (a_ra_idx); @@ -846,7 +846,7 @@ std::ostream& operator << (std::ostream& os, const ComplexNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); for (octave_idx_type i = 0; i < nel; i++) { @@ -860,7 +860,7 @@ std::istream& operator >> (std::istream& is, ComplexNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); if (nel > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/CRowVector.cc --- a/liboctave/array/CRowVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/CRowVector.cc Sat May 30 05:39:47 2015 -0400 @@ -59,8 +59,8 @@ bool ComplexRowVector::operator == (const ComplexRowVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -76,9 +76,9 @@ ComplexRowVector& ComplexRowVector::insert (const RowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -98,9 +98,9 @@ ComplexRowVector& ComplexRowVector::insert (const ComplexRowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -120,7 +120,7 @@ ComplexRowVector& ComplexRowVector::fill (double val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -136,7 +136,7 @@ ComplexRowVector& ComplexRowVector::fill (const Complex& val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -152,7 +152,7 @@ ComplexRowVector& ComplexRowVector::fill (double val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -177,7 +177,7 @@ ComplexRowVector::fill (const Complex& val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -201,9 +201,9 @@ ComplexRowVector ComplexRowVector::append (const RowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - ComplexRowVector retval (len + a.length ()); + ComplexRowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -212,9 +212,9 @@ ComplexRowVector ComplexRowVector::append (const ComplexRowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - ComplexRowVector retval (len + a.length ()); + ComplexRowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -271,9 +271,9 @@ ComplexRowVector& ComplexRowVector::operator += (const RowVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -293,9 +293,9 @@ ComplexRowVector& ComplexRowVector::operator -= (const RowVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -319,7 +319,7 @@ { ComplexRowVector retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); octave_idx_type a_nr = a.rows (); octave_idx_type a_nc = a.cols (); @@ -361,7 +361,7 @@ Complex ComplexRowVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return Complex (0.0); @@ -381,7 +381,7 @@ Complex ComplexRowVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return Complex (0.0); @@ -404,7 +404,7 @@ operator << (std::ostream& os, const ComplexRowVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << " " /* setw (field_width) */ << a.elem (i); return os; } @@ -412,7 +412,7 @@ std::istream& operator >> (std::istream& is, ComplexRowVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { @@ -445,9 +445,9 @@ { Complex retval (0.0, 0.0); - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) gripe_nonconformant ("operator *", len, a_len); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/DiagArray2.cc --- a/liboctave/array/DiagArray2.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/DiagArray2.cc Sat May 30 05:39:47 2015 -0400 @@ -42,7 +42,7 @@ : Array (a.as_column ()), d1 (r), d2 (c) { octave_idx_type rcmin = std::min (r, c); - if (rcmin != a.length ()) + if (rcmin != a.numel ()) Array::resize (dim_vector (rcmin, 1)); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/DiagArray2.h --- a/liboctave/array/DiagArray2.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/DiagArray2.h Sat May 30 05:39:47 2015 -0400 @@ -87,9 +87,9 @@ octave_idx_type cols (void) const { return dim2 (); } octave_idx_type columns (void) const { return dim2 (); } - octave_idx_type diag_length (void) const { return Array::length (); } + octave_idx_type diag_length (void) const { return Array::numel (); } // FIXME: a dangerous ambiguity? - octave_idx_type length (void) const { return Array::length (); } + octave_idx_type length (void) const { return Array::numel (); } octave_idx_type nelem (void) const { return dim1 () * dim2 (); } octave_idx_type numel (void) const { return nelem (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/MArray.cc --- a/liboctave/array/MArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/MArray.cc Sat May 30 05:39:47 2015 -0400 @@ -56,7 +56,7 @@ void MArray::idx_add (const idx_vector& idx, T val) { - octave_idx_type n = this->length (); + octave_idx_type n = this->numel (); octave_idx_type ext = idx.extent (n); if (ext > n) { @@ -74,7 +74,7 @@ void MArray::idx_add (const idx_vector& idx, const MArray& vals) { - octave_idx_type n = this->length (); + octave_idx_type n = this->numel (); octave_idx_type ext = idx.extent (n); if (ext > n) { @@ -84,7 +84,7 @@ octave_quit (); - octave_idx_type len = std::min (idx.length (n), vals.length ()); + octave_idx_type len = std::min (idx.length (n), vals.numel ()); idx.loop (len, _idxadda_helper (this->fortran_vec (), vals.data ())); } @@ -103,7 +103,7 @@ void MArray::idx_min (const idx_vector& idx, const MArray& vals) { - octave_idx_type n = this->length (); + octave_idx_type n = this->numel (); octave_idx_type ext = idx.extent (n); if (ext > n) { @@ -113,7 +113,7 @@ octave_quit (); - octave_idx_type len = std::min (idx.length (n), vals.length ()); + octave_idx_type len = std::min (idx.length (n), vals.numel ()); idx.loop (len, _idxbinop_helper (this->fortran_vec (), vals.data ())); } @@ -122,7 +122,7 @@ void MArray::idx_max (const idx_vector& idx, const MArray& vals) { - octave_idx_type n = this->length (); + octave_idx_type n = this->numel (); octave_idx_type ext = idx.extent (n); if (ext > n) { @@ -132,7 +132,7 @@ octave_quit (); - octave_idx_type len = std::min (idx.length (n), vals.length ()); + octave_idx_type len = std::min (idx.length (n), vals.numel ()); idx.loop (len, _idxbinop_helper (this->fortran_vec (), vals.data ())); } @@ -153,7 +153,7 @@ dim_vector ddv = Array::dims ().redim (nd); dim_vector sdv = vals.dims ().redim (nd); - octave_idx_type ext = idx.extent (ddv (dim)); + octave_idx_type ext = idx.extent (ddv(dim)); if (ext > ddv(dim)) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/PermMatrix.cc --- a/liboctave/array/PermMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/PermMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -41,7 +41,7 @@ { if (check) { - if (! idx_vector (p).is_permutation (p.length ())) + if (! idx_vector (p).is_permutation (p.numel ())) { gripe_invalid_permutation (); Array::operator = (Array ()); @@ -104,7 +104,7 @@ octave_idx_type PermMatrix::checkelem (octave_idx_type i, octave_idx_type j) const { - octave_idx_type len = Array::length (); + octave_idx_type len = Array::numel (); if (i < 0 || j < 0 || i > len || j > len) { (*current_liboctave_error_handler) ("index out of range"); @@ -118,7 +118,7 @@ PermMatrix PermMatrix::transpose (void) const { - octave_idx_type len = Array::length (); + octave_idx_type len = Array::numel (); PermMatrix retval (len); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/PermMatrix.h --- a/liboctave/array/PermMatrix.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/PermMatrix.h Sat May 30 05:39:47 2015 -0400 @@ -48,21 +48,21 @@ PermMatrix (const idx_vector& idx, bool colp, octave_idx_type n = 0); octave_idx_type dim1 (void) const - { return Array::length (); } + { return Array::numel (); } octave_idx_type dim2 (void) const - { return Array::length (); } + { return Array::numel (); } octave_idx_type rows (void) const { return dim1 (); } octave_idx_type cols (void) const { return dim2 (); } octave_idx_type columns (void) const { return dim2 (); } octave_idx_type perm_length (void) const - { return Array::length (); } + { return Array::numel (); } // FIXME: a dangerous ambiguity? octave_idx_type length (void) const { return perm_length (); } - octave_idx_type nelem (void) const { return dim1 () * dim2 (); } - octave_idx_type numel (void) const { return nelem (); } + GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); } + octave_idx_type numel (void) const { return dim1 () * dim2 (); } size_t byte_size (void) const { return Array::byte_size (); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Range.cc --- a/liboctave/array/Range.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Range.cc Sat May 30 05:39:47 2015 -0400 @@ -44,24 +44,24 @@ // or fewer elements only the base needs to be an integer return (! (xisnan (rng_base) || xisnan (rng_inc)) - && (NINTbig (rng_base) == rng_base || rng_nelem < 1) - && (NINTbig (rng_inc) == rng_inc || rng_nelem <= 1)); + && (NINTbig (rng_base) == rng_base || rng_numel < 1) + && (NINTbig (rng_inc) == rng_inc || rng_numel <= 1)); } Matrix Range::matrix_value (void) const { - if (rng_nelem > 0 && cache.nelem () == 0) + if (rng_numel > 0 && cache.numel () == 0) { - cache.resize (1, rng_nelem); + cache.resize (1, rng_numel); double b = rng_base; double increment = rng_inc; - if (rng_nelem > 0) + if (rng_numel > 0) { // The first element must always be *exactly* the base. // E.g, -0 would otherwise become +0 in the loop (-0 + 0*increment). cache(0) = b; - for (octave_idx_type i = 1; i < rng_nelem; i++) + for (octave_idx_type i = 1; i < rng_numel; i++) cache(i) = b + i * increment; } @@ -72,9 +72,9 @@ // elements. The tests need equality (>= rng_limit or <= rng_limit) // to have expressions like -5:1:-0 result in a -0 endpoint. - if ((rng_inc > 0 && cache(rng_nelem-1) >= rng_limit) - || (rng_inc < 0 && cache(rng_nelem-1) <= rng_limit)) - cache(rng_nelem-1) = rng_limit; + if ((rng_inc > 0 && cache(rng_numel-1) >= rng_limit) + || (rng_inc < 0 && cache(rng_numel-1) <= rng_limit)) + cache(rng_numel-1) = rng_limit; } return cache; @@ -83,12 +83,12 @@ double Range::checkelem (octave_idx_type i) const { - if (i < 0 || i >= rng_nelem) - gripe_index_out_of_range (1, 1, i+1, rng_nelem); + if (i < 0 || i >= rng_numel) + gripe_index_out_of_range (1, 1, i+1, rng_numel); if (i == 0) return rng_base; - else if (i < rng_nelem - 1) + else if (i < rng_numel - 1) return rng_base + i * rng_inc; else { @@ -109,7 +109,7 @@ #else if (i == 0) return rng_base; - else if (i < rng_nelem - 1) + else if (i < rng_numel - 1) return rng_base + i * rng_inc; else { @@ -158,11 +158,11 @@ { Array retval; - octave_idx_type n = rng_nelem; + octave_idx_type n = rng_numel; if (i.is_colon ()) { - retval = matrix_value ().reshape (dim_vector (rng_nelem, 1)); + retval = matrix_value ().reshape (dim_vector (rng_numel, 1)); } else { @@ -181,26 +181,26 @@ // idx_vector loop across all values in i, // executing __rangeidx_helper (i) for each i i.loop (n, __rangeidx_helper (retval.fortran_vec (), - rng_base, rng_inc, rng_limit, rng_nelem)); + rng_base, rng_inc, rng_limit, rng_numel)); } return retval; } -// NOTE: max and min only return useful values if nelem > 0. -// do_minmax_body() in max.cc avoids calling Range::min/max if nelem == 0. +// NOTE: max and min only return useful values if numel > 0. +// do_minmax_body() in max.cc avoids calling Range::min/max if numel == 0. double Range::min (void) const { double retval = 0.0; - if (rng_nelem > 0) + if (rng_numel > 0) { if (rng_inc > 0) retval = rng_base; else { - retval = rng_base + (rng_nelem - 1) * rng_inc; + retval = rng_base + (rng_numel - 1) * rng_inc; // See the note in the matrix_value method above. if (retval <= rng_limit) @@ -215,11 +215,11 @@ Range::max (void) const { double retval = 0.0; - if (rng_nelem > 0) + if (rng_numel > 0) { if (rng_inc > 0) { - retval = rng_base + (rng_nelem - 1) * rng_inc; + retval = rng_base + (rng_numel - 1) * rng_inc; // See the note in the matrix_value method above. if (retval >= rng_limit) @@ -255,7 +255,7 @@ void Range::sort_internal (Array& sidx, bool ascending) { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); sidx.resize (dim_vector (1, nel)); @@ -336,9 +336,9 @@ sortmode Range::is_sorted (sortmode mode) const { - if (rng_nelem > 1 && rng_inc > 0) + if (rng_numel > 1 && rng_inc > 0) mode = (mode == DESCENDING) ? UNSORTED : ASCENDING; - else if (rng_nelem > 1 && rng_inc < 0) + else if (rng_numel > 1 && rng_inc < 0) mode = (mode == ASCENDING) ? UNSORTED : DESCENDING; else mode = mode ? mode : ASCENDING; @@ -351,7 +351,7 @@ { double b = a.base (); double increment = a.inc (); - octave_idx_type num_elem = a.nelem (); + octave_idx_type num_elem = a.numel (); if (num_elem > 1) { @@ -377,7 +377,7 @@ if (is) { is >> a.rng_inc; - a.rng_nelem = a.nelem_internal (); + a.rng_numel = a.numel_internal (); } } @@ -387,13 +387,13 @@ Range operator - (const Range& r) { - return Range (-r.base (), -r.limit (), -r.inc (), r.nelem ()); + return Range (-r.base (), -r.limit (), -r.inc (), r.numel ()); } Range operator + (double x, const Range& r) { - Range result (x + r.base (), x + r.limit (), r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x + r.base (), x + r.limit (), r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x + r.matrix_value (); return result; @@ -401,8 +401,8 @@ Range operator + (const Range& r, double x) { - Range result (r.base () + x, r.limit () + x, r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () + x, r.limit () + x, r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () + x; return result; @@ -410,8 +410,8 @@ Range operator - (double x, const Range& r) { - Range result (x - r.base (), x - r.limit (), -r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x - r.base (), x - r.limit (), -r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x - r.matrix_value (); return result; @@ -419,8 +419,8 @@ Range operator - (const Range& r, double x) { - Range result (r.base () - x, r.limit () - x, r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () - x, r.limit () - x, r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () - x; return result; @@ -428,8 +428,8 @@ Range operator * (double x, const Range& r) { - Range result (x * r.base (), x * r.limit (), x * r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x * r.base (), x * r.limit (), x * r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x * r.matrix_value (); return result; @@ -437,8 +437,8 @@ Range operator * (const Range& r, double x) { - Range result (r.base () * x, r.limit () * x, r.inc () * x, r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () * x, r.limit () * x, r.inc () * x, r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () * x; return result; @@ -524,7 +524,7 @@ } octave_idx_type -Range::nelem_internal (void) const +Range::numel_internal (void) const { octave_idx_type retval = -1; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Range.h --- a/liboctave/array/Range.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Range.h Sat May 30 05:39:47 2015 -0400 @@ -35,33 +35,34 @@ public: Range (void) - : rng_base (0), rng_limit (0), rng_inc (0), rng_nelem (0), cache (1, 0) { } + : rng_base (0), rng_limit (0), rng_inc (0), rng_numel (0), cache (1, 0) { } Range (const Range& r) : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc), - rng_nelem (r.rng_nelem), cache (r.cache) { } + rng_numel (r.rng_numel), cache (r.cache) { } Range (double b, double l) : rng_base (b), rng_limit (l), rng_inc (1), - rng_nelem (nelem_internal ()), cache () { } + rng_numel (numel_internal ()), cache () { } Range (double b, double l, double i) : rng_base (b), rng_limit (l), rng_inc (i), - rng_nelem (nelem_internal ()), cache () { } + rng_numel (numel_internal ()), cache () { } // For operators' usage (to preserve element count). Range (double b, double i, octave_idx_type n) : rng_base (b), rng_limit (b + (n-1) * i), rng_inc (i), - rng_nelem (n), cache () + rng_numel (n), cache () { if (! xfinite (b) || ! xfinite (i) || ! xfinite (rng_limit)) - rng_nelem = -2; + rng_numel = -2; } double base (void) const { return rng_base; } double limit (void) const { return rng_limit; } double inc (void) const { return rng_inc; } - octave_idx_type nelem (void) const { return rng_nelem; } + GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); } + octave_idx_type numel (void) const { return rng_numel; } bool all_elements_are_ints (void) const; @@ -137,11 +138,11 @@ double rng_limit; double rng_inc; - octave_idx_type rng_nelem; + octave_idx_type rng_numel; mutable Matrix cache; - octave_idx_type nelem_internal (void) const; + octave_idx_type numel_internal (void) const; void clear_cache (void) const { cache.resize (0, 0); } @@ -150,10 +151,10 @@ // For operators' usage (to allow all values to be set directly). Range (double b, double l, double i, octave_idx_type n) : rng_base (b), rng_limit (l), rng_inc (i), - rng_nelem (n), cache () + rng_numel (n), cache () { if (! xfinite (b) || ! xfinite (i) || ! xfinite (l)) - rng_nelem = -2; + rng_numel = -2; } }; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Sparse.cc --- a/liboctave/array/Sparse.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Sparse.cc Sat May 30 05:39:47 2015 -0400 @@ -239,8 +239,8 @@ // Work in unsigned long long to avoid overflow issues with numel unsigned long long a_nel = static_cast(a.rows ()) * static_cast(a.cols ()); - unsigned long long dv_nel = static_cast(dv (0)) * - static_cast(dv (1)); + unsigned long long dv_nel = static_cast(dv(0)) * + static_cast(dv(1)); if (a_nel != dv_nel) (*current_liboctave_error_handler) @@ -249,10 +249,10 @@ { dim_vector old_dims = a.dims (); octave_idx_type new_nzmx = a.nnz (); - octave_idx_type new_nr = dv (0); - octave_idx_type new_nc = dv (1); - octave_idx_type old_nr = old_dims (0); - octave_idx_type old_nc = old_dims (1); + octave_idx_type new_nr = dv(0); + octave_idx_type new_nc = dv(1); + octave_idx_type old_nr = old_dims(0); + octave_idx_type old_nc = old_dims(1); rep = new typename Sparse::SparseRep (new_nr, new_nc, new_nzmx); @@ -646,7 +646,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); octave_idx_type new_nzmx = 0; // First count the number of nonzero terms @@ -704,7 +704,7 @@ octave_idx_type n = dimensions.length (); - if (n > 0 && n == ra_idx.length ()) + if (n > 0 && n == ra_idx.numel ()) { retval = ra_idx(--n); @@ -767,7 +767,7 @@ buf << fcn << " ("; - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); if (n > 0) buf << ra_idx(0); @@ -792,7 +792,7 @@ buf << fcn << " ("; - octave_idx_type n = ra_idx.length (); + octave_idx_type n = ra_idx.numel (); if (n > 0) buf << ra_idx(0); @@ -886,7 +886,7 @@ bool fail = false; bool trans = false; - if (perm_vec.length () == 2) + if (perm_vec.numel () == 2) { if (perm_vec(0) == 0 && perm_vec(1) == 1) /* do nothing */; @@ -1082,13 +1082,13 @@ Sparse::insert (const Sparse& a, const Array& ra_idx) { - if (ra_idx.length () != 2) + if (ra_idx.numel () != 2) { (*current_liboctave_error_handler) ("range error for insert"); return *this; } - return insert (a, ra_idx (0), ra_idx (1)); + return insert (a, ra_idx(0), ra_idx(1)); } template @@ -1879,7 +1879,7 @@ octave_idx_type rnz = rhs.nnz (); octave_idx_type new_nz = nz - (ui - li) + rnz; - if (new_nz >= nz && new_nz <= capacity ()) + if (new_nz >= nz && new_nz <= nzmax ()) { // Adding/overwriting elements, enough capacity allocated. @@ -2062,7 +2062,7 @@ octave_idx_type rnz = rhs.nnz (); octave_idx_type new_nz = nz - (ui - li) + rnz; - if (new_nz >= nz && new_nz <= capacity ()) + if (new_nz >= nz && new_nz <= nzmax ()) { // Adding/overwriting elements, enough capacity allocated. @@ -2244,7 +2244,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); - if (m.length () < 1 || dim > 1) + if (m.numel () < 1 || dim > 1) return m; if (dim > 0) @@ -2310,7 +2310,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.columns (); - if (m.length () < 1 || dim > 1) + if (m.numel () < 1 || dim > 1) { sidx = Array (dim_vector (nr, nc), 1); return m; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/Sparse.h --- a/liboctave/array/Sparse.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/Sparse.h Sat May 30 05:39:47 2015 -0400 @@ -240,11 +240,13 @@ Sparse& operator = (const Sparse& a); - // Note that nzmax and capacity are the amount of storage for - // nonzero elements, while nnz is the actual number of nonzero - // terms. + //! Amount of storage for nonzero elements. + //! This may differ from the actual number of elements, see nnz(). octave_idx_type nzmax (void) const { return rep->length (); } - octave_idx_type capacity (void) const { return nzmax (); } + //! Amount of storage for nonzero elements. + //! Synonymous with nzmax(). + GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); } + //!Actual number of nonzero terms. octave_idx_type nnz (void) const { return rep->nnz (); } // Querying the number of elements (incl. zeros) may overflow the index type, @@ -254,8 +256,8 @@ return dimensions.safe_numel (); } - octave_idx_type nelem (void) const { return capacity (); } - octave_idx_type length (void) const { return numel (); } + GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return nzmax (); } + GCC_ATTR_DEPRECATED octave_idx_type length (void) const { return numel (); } octave_idx_type dim1 (void) const { return dimensions(0); } octave_idx_type dim2 (void) const { return dimensions(1); } @@ -276,7 +278,7 @@ size_t byte_size (void) const { return (static_cast(cols () + 1) * sizeof (octave_idx_type) - + static_cast (capacity ()) + + static_cast (nzmax ()) * (sizeof (T) + sizeof (octave_idx_type))); } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/boolMatrix.cc --- a/liboctave/array/boolMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/boolMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -43,7 +43,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return 0; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/chMatrix.cc --- a/liboctave/array/chMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/chMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -45,7 +45,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return 0; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/chNDArray.cc --- a/liboctave/array/chNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/chNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -70,7 +70,7 @@ } charNDArray::charNDArray (const string_vector& s, char fill_value) - : Array (dim_vector (s.length (), s.max_length ()), fill_value) + : Array (dim_vector (s.numel (), s.max_length ()), fill_value) { octave_idx_type nr = rows (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dColVector.cc --- a/liboctave/array/dColVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dColVector.cc Sat May 30 05:39:47 2015 -0400 @@ -55,8 +55,8 @@ bool ColumnVector::operator == (const ColumnVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -70,9 +70,9 @@ ColumnVector& ColumnVector::insert (const ColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -92,7 +92,7 @@ ColumnVector& ColumnVector::fill (double val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -108,7 +108,7 @@ ColumnVector& ColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -132,9 +132,9 @@ ColumnVector ColumnVector::stack (const ColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - ColumnVector retval (len + a.length ()); + ColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -202,7 +202,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -239,7 +239,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -267,7 +267,7 @@ double ColumnVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -283,7 +283,7 @@ double ColumnVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -300,7 +300,7 @@ operator << (std::ostream& os, const ColumnVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << /* setw (field_width) << */ a.elem (i) << "\n"; return os; } @@ -308,7 +308,7 @@ std::istream& operator >> (std::istream& is, ColumnVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dDiagMatrix.cc --- a/liboctave/array/dDiagMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dDiagMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -78,7 +78,7 @@ DiagMatrix::fill (const ColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -94,7 +94,7 @@ DiagMatrix::fill (const RowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -109,7 +109,7 @@ DiagMatrix& DiagMatrix::fill (const ColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -125,7 +125,7 @@ DiagMatrix& DiagMatrix::fill (const RowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dMatrix.cc --- a/liboctave/array/dMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -306,7 +306,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return false; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool @@ -341,7 +341,7 @@ Matrix& Matrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { @@ -363,7 +363,7 @@ Matrix& Matrix::insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -486,7 +486,7 @@ } octave_idx_type nc_insert = nc; - Matrix retval (nr, nc + a.length ()); + Matrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -497,7 +497,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return Matrix (); @@ -552,7 +552,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -579,7 +579,7 @@ } octave_idx_type nr_insert = nr; - Matrix retval (nr + a.length (), nc); + Matrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -877,7 +877,7 @@ ColumnVector sigma = S.extract_diag (); - octave_idx_type r = sigma.length () - 1; + octave_idx_type r = sigma.numel () - 1; octave_idx_type nr = rows (); octave_idx_type nc = cols (); @@ -967,7 +967,7 @@ ComplexMatrix Matrix::fourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); const double *in = fortran_vec (); ComplexMatrix retval (rows (), cols ()); @@ -979,7 +979,7 @@ ComplexMatrix Matrix::ifourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); ComplexMatrix retval (*this); Complex *out (retval.fortran_vec ()); @@ -2467,7 +2467,7 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m != b.length ()) + if (m != b.numel ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); else if (m == 0 || n == 0) @@ -2636,11 +2636,11 @@ { Matrix retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); if (len != 0) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); retval = Matrix (len, a_len); double *c = retval.fortran_vec (); @@ -3332,9 +3332,9 @@ { if (n < 1) n = 1; - octave_idx_type m = x1.length (); - - if (x2.length () != m) + octave_idx_type m = x1.numel (); + + if (x2.numel () != m) (*current_liboctave_error_handler) ("linspace: vectors must be of equal length"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dNDArray.cc --- a/liboctave/array/dNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -110,9 +110,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const double *in (fortran_vec ()); @@ -141,9 +141,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); ComplexNDArray retval (*this); @@ -164,7 +164,7 @@ if (dv.length () < 2) return ComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const double *in = fortran_vec (); ComplexNDArray retval (dv); Complex *out = retval.fortran_vec (); @@ -184,7 +184,7 @@ if (dv.length () < 2) return ComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); ComplexNDArray retval (*this); Complex *out = retval.fortran_vec (); octave_idx_type howmany = numel () / dv(0) / dv(1); @@ -596,7 +596,7 @@ bool NDArray::all_integers (double& max_val, double& min_val) const { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); if (nel > 0) { @@ -872,7 +872,7 @@ std::ostream& operator << (std::ostream& os, const NDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); for (octave_idx_type i = 0; i < nel; i++) { @@ -886,7 +886,7 @@ std::istream& operator >> (std::istream& is, NDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); if (nel > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dRowVector.cc --- a/liboctave/array/dRowVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dRowVector.cc Sat May 30 05:39:47 2015 -0400 @@ -58,8 +58,8 @@ bool RowVector::operator == (const RowVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -73,9 +73,9 @@ RowVector& RowVector::insert (const RowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -95,7 +95,7 @@ RowVector& RowVector::fill (double val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -111,7 +111,7 @@ RowVector& RowVector::fill (double val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -135,9 +135,9 @@ RowVector RowVector::append (const RowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - RowVector retval (len + a.length ()); + RowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -194,7 +194,7 @@ { RowVector retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); octave_idx_type a_nr = a.rows (); octave_idx_type a_nc = a.cols (); @@ -229,7 +229,7 @@ double RowVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0; @@ -245,7 +245,7 @@ double RowVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0; @@ -263,7 +263,7 @@ { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << " " /* setw (field_width) */ << a.elem (i); return os; } @@ -271,7 +271,7 @@ std::istream& operator >> (std::istream& is, RowVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { @@ -313,9 +313,9 @@ { double retval = 0.0; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) gripe_nonconformant ("operator *", len, a_len); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/dim-vector.h --- a/liboctave/array/dim-vector.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/dim-vector.h Sat May 30 05:39:47 2015 -0400 @@ -458,7 +458,7 @@ { octave_idx_type k = 0; for (int i = length () - 1; i >= 0; i--) - k = k * rep[i] + idx[i]; + k = rep[i] * k + idx[i]; return k; } @@ -469,7 +469,7 @@ { octave_idx_type k = 0; for (int i = nidx - 1; i >= 0; i--) - k = k * rep[i] + idx[i]; + k = rep[i] * k + idx[i]; return k; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fCColVector.cc --- a/liboctave/array/fCColVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fCColVector.cc Sat May 30 05:39:47 2015 -0400 @@ -60,8 +60,8 @@ bool FloatComplexColumnVector::operator == (const FloatComplexColumnVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -77,9 +77,9 @@ FloatComplexColumnVector& FloatComplexColumnVector::insert (const FloatColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -100,9 +100,9 @@ FloatComplexColumnVector::insert (const FloatComplexColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -122,7 +122,7 @@ FloatComplexColumnVector& FloatComplexColumnVector::fill (float val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -138,7 +138,7 @@ FloatComplexColumnVector& FloatComplexColumnVector::fill (const FloatComplex& val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -156,7 +156,7 @@ FloatComplexColumnVector::fill (float val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -181,7 +181,7 @@ FloatComplexColumnVector::fill (const FloatComplex& val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -205,9 +205,9 @@ FloatComplexColumnVector FloatComplexColumnVector::stack (const FloatColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - FloatComplexColumnVector retval (len + a.length ()); + FloatComplexColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -216,9 +216,9 @@ FloatComplexColumnVector FloatComplexColumnVector::stack (const FloatComplexColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - FloatComplexColumnVector retval (len + a.length ()); + FloatComplexColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -282,9 +282,9 @@ FloatComplexColumnVector& FloatComplexColumnVector::operator += (const FloatColumnVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -304,9 +304,9 @@ FloatComplexColumnVector& FloatComplexColumnVector::operator -= (const FloatColumnVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -340,7 +340,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -384,7 +384,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -412,7 +412,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -440,7 +440,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) { @@ -467,7 +467,7 @@ FloatComplex FloatComplexColumnVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -487,7 +487,7 @@ FloatComplex FloatComplexColumnVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -510,7 +510,7 @@ operator << (std::ostream& os, const FloatComplexColumnVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << /* setw (field_width) << */ a.elem (i) << "\n"; return os; } @@ -518,7 +518,7 @@ std::istream& operator >> (std::istream& is, FloatComplexColumnVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fCDiagMatrix.cc --- a/liboctave/array/fCDiagMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fCDiagMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -111,7 +111,7 @@ FloatComplexDiagMatrix::fill (const FloatColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -127,7 +127,7 @@ FloatComplexDiagMatrix::fill (const FloatComplexColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -143,7 +143,7 @@ FloatComplexDiagMatrix::fill (const FloatRowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -159,7 +159,7 @@ FloatComplexDiagMatrix::fill (const FloatComplexRowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -174,7 +174,7 @@ FloatComplexDiagMatrix& FloatComplexDiagMatrix::fill (const FloatColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -191,7 +191,7 @@ FloatComplexDiagMatrix::fill (const FloatComplexColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -207,7 +207,7 @@ FloatComplexDiagMatrix& FloatComplexDiagMatrix::fill (const FloatRowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -224,7 +224,7 @@ FloatComplexDiagMatrix::fill (const FloatComplexRowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fCMatrix.cc --- a/liboctave/array/fCMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fCMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -369,7 +369,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return false; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool @@ -428,7 +428,7 @@ FloatComplexMatrix::insert (const FloatRowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { @@ -451,7 +451,7 @@ FloatComplexMatrix::insert (const FloatColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -510,7 +510,7 @@ FloatComplexMatrix::insert (const FloatComplexRowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { (*current_liboctave_error_handler) ("range error for insert"); @@ -527,7 +527,7 @@ FloatComplexMatrix::insert (const FloatComplexColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -699,7 +699,7 @@ } octave_idx_type nc_insert = nc; - FloatComplexMatrix retval (nr, nc + a.length ()); + FloatComplexMatrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -710,7 +710,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return *this; @@ -771,7 +771,7 @@ } octave_idx_type nc_insert = nc; - FloatComplexMatrix retval (nr, nc + a.length ()); + FloatComplexMatrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -782,7 +782,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return *this; @@ -837,7 +837,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -864,7 +864,7 @@ } octave_idx_type nr_insert = nr; - FloatComplexMatrix retval (nr + a.length (), nc); + FloatComplexMatrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -913,7 +913,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -940,7 +940,7 @@ } octave_idx_type nr_insert = nr; - FloatComplexMatrix retval (nr + a.length (), nc); + FloatComplexMatrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -1236,7 +1236,7 @@ FloatColumnVector sigma = S.extract_diag (); - octave_idx_type r = sigma.length () - 1; + octave_idx_type r = sigma.numel () - 1; octave_idx_type nr = rows (); octave_idx_type nc = cols (); @@ -1327,7 +1327,7 @@ FloatComplexMatrix FloatComplexMatrix::fourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); FloatComplexMatrix retval (rows (), cols ()); const FloatComplex *in (data ()); @@ -1341,7 +1341,7 @@ FloatComplexMatrix FloatComplexMatrix::ifourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); FloatComplexMatrix retval (rows (), cols ()); const FloatComplex *in (data ()); @@ -2862,7 +2862,7 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m != b.length ()) + if (m != b.numel ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); else if (m == 0 || n == 0 || b.cols () == 0) @@ -2975,11 +2975,11 @@ { FloatComplexMatrix retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); if (len != 0) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); retval = FloatComplexMatrix (len, a_len); FloatComplex *c = retval.fortran_vec (); @@ -3103,7 +3103,7 @@ FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates! - mx_inline_add2 (length (), d, a.data ()); + mx_inline_add2 (numel (), d, a.data ()); return *this; } @@ -3127,7 +3127,7 @@ FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates! - mx_inline_sub2 (length (), d, a.data ()); + mx_inline_sub2 (numel (), d, a.data ()); return *this; } @@ -4021,9 +4021,9 @@ { if (n < 1) n = 1; - octave_idx_type m = x1.length (); - - if (x2.length () != m) + octave_idx_type m = x1.numel (); + + if (x2.numel () != m) (*current_liboctave_error_handler) ("linspace: vectors must be of equal length"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fCNDArray.cc --- a/liboctave/array/fCNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fCNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -69,9 +69,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const FloatComplex *in (fortran_vec ()); @@ -100,9 +100,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const FloatComplex *in (fortran_vec ()); @@ -124,7 +124,7 @@ if (dv.length () < 2) return FloatComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const FloatComplex *in = fortran_vec (); FloatComplexNDArray retval (dv); FloatComplex *out = retval.fortran_vec (); @@ -144,7 +144,7 @@ if (dv.length () < 2) return FloatComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const FloatComplex *in = fortran_vec (); FloatComplexNDArray retval (dv); FloatComplex *out = retval.fortran_vec (); @@ -532,7 +532,7 @@ bool FloatComplexNDArray::all_integers (float& max_val, float& min_val) const { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); if (nel > 0) { @@ -776,7 +776,7 @@ for (int i = 0; i < n; i++) { - if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i)) + if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i)) { (*current_liboctave_error_handler) ("Array::insert: range error for insert"); @@ -789,14 +789,14 @@ octave_idx_type n_elt = a.numel (); - // IS make_unique () NECCESSARY HERE?? + // IS make_unique () NECESSARY HERE? for (octave_idx_type i = 0; i < n_elt; i++) { Array ra_idx = a_ra_idx; - ra_idx.elem (0) = a_ra_idx (0) + r; - ra_idx.elem (1) = a_ra_idx (1) + c; + ra_idx.elem (0) = a_ra_idx(0) + r; + ra_idx.elem (1) = a_ra_idx(1) + c; elem (ra_idx) = a.elem (a_ra_idx); @@ -857,7 +857,7 @@ std::ostream& operator << (std::ostream& os, const FloatComplexNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); for (octave_idx_type i = 0; i < nel; i++) { @@ -871,7 +871,7 @@ std::istream& operator >> (std::istream& is, FloatComplexNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); if (nel > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fCRowVector.cc --- a/liboctave/array/fCRowVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fCRowVector.cc Sat May 30 05:39:47 2015 -0400 @@ -59,8 +59,8 @@ bool FloatComplexRowVector::operator == (const FloatComplexRowVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -76,9 +76,9 @@ FloatComplexRowVector& FloatComplexRowVector::insert (const FloatRowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -99,9 +99,9 @@ FloatComplexRowVector::insert (const FloatComplexRowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -121,7 +121,7 @@ FloatComplexRowVector& FloatComplexRowVector::fill (float val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -137,7 +137,7 @@ FloatComplexRowVector& FloatComplexRowVector::fill (const FloatComplex& val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -153,7 +153,7 @@ FloatComplexRowVector& FloatComplexRowVector::fill (float val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -178,7 +178,7 @@ FloatComplexRowVector::fill (const FloatComplex& val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -202,9 +202,9 @@ FloatComplexRowVector FloatComplexRowVector::append (const FloatRowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - FloatComplexRowVector retval (len + a.length ()); + FloatComplexRowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -213,9 +213,9 @@ FloatComplexRowVector FloatComplexRowVector::append (const FloatComplexRowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - FloatComplexRowVector retval (len + a.length ()); + FloatComplexRowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -272,9 +272,9 @@ FloatComplexRowVector& FloatComplexRowVector::operator += (const FloatRowVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -294,9 +294,9 @@ FloatComplexRowVector& FloatComplexRowVector::operator -= (const FloatRowVector& a) { - octave_idx_type len = length (); + octave_idx_type len = numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) { @@ -320,7 +320,7 @@ { FloatComplexRowVector retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); octave_idx_type a_nr = a.rows (); octave_idx_type a_nc = a.cols (); @@ -362,7 +362,7 @@ FloatComplex FloatComplexRowVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return FloatComplex (0.0); @@ -382,7 +382,7 @@ FloatComplex FloatComplexRowVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return FloatComplex (0.0); @@ -405,7 +405,7 @@ operator << (std::ostream& os, const FloatComplexRowVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << " " /* setw (field_width) */ << a.elem (i); return os; } @@ -413,7 +413,7 @@ std::istream& operator >> (std::istream& is, FloatComplexRowVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { @@ -446,9 +446,9 @@ { FloatComplex retval (0.0, 0.0); - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) gripe_nonconformant ("operator *", len, a_len); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fColVector.cc --- a/liboctave/array/fColVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fColVector.cc Sat May 30 05:39:47 2015 -0400 @@ -54,8 +54,8 @@ bool FloatColumnVector::operator == (const FloatColumnVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -69,9 +69,9 @@ FloatColumnVector& FloatColumnVector::insert (const FloatColumnVector& a, octave_idx_type r) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (r < 0 || r + a_len > length ()) + if (r < 0 || r + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -91,7 +91,7 @@ FloatColumnVector& FloatColumnVector::fill (float val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -107,7 +107,7 @@ FloatColumnVector& FloatColumnVector::fill (float val, octave_idx_type r1, octave_idx_type r2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) { @@ -131,9 +131,9 @@ FloatColumnVector FloatColumnVector::stack (const FloatColumnVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nr_insert = len; - FloatColumnVector retval (len + a.length ()); + FloatColumnVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nr_insert); return retval; @@ -201,7 +201,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -238,7 +238,7 @@ octave_idx_type nr = m.rows (); octave_idx_type nc = m.cols (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (nc != a_len) gripe_nonconformant ("operator *", nr, nc, a_len, 1); @@ -266,7 +266,7 @@ float FloatColumnVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -282,7 +282,7 @@ float FloatColumnVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0.0; @@ -299,7 +299,7 @@ operator << (std::ostream& os, const FloatColumnVector& a) { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << /* setw (field_width) << */ a.elem (i) << "\n"; return os; } @@ -307,7 +307,7 @@ std::istream& operator >> (std::istream& is, FloatColumnVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fDiagMatrix.cc --- a/liboctave/array/fDiagMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fDiagMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -78,7 +78,7 @@ FloatDiagMatrix::fill (const FloatColumnVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -94,7 +94,7 @@ FloatDiagMatrix::fill (const FloatRowVector& a) { octave_idx_type len = length (); - if (a.length () != len) + if (a.numel () != len) { (*current_liboctave_error_handler) ("range error for fill"); return *this; @@ -109,7 +109,7 @@ FloatDiagMatrix& FloatDiagMatrix::fill (const FloatColumnVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); @@ -125,7 +125,7 @@ FloatDiagMatrix& FloatDiagMatrix::fill (const FloatRowVector& a, octave_idx_type beg) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (beg < 0 || beg + a_len >= length ()) { (*current_liboctave_error_handler) ("range error for fill"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fMatrix.cc --- a/liboctave/array/fMatrix.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fMatrix.cc Sat May 30 05:39:47 2015 -0400 @@ -309,7 +309,7 @@ if (rows () != a.rows () || cols () != a.cols ()) return false; - return mx_inline_equal (length (), data (), a.data ()); + return mx_inline_equal (numel (), data (), a.data ()); } bool @@ -346,7 +346,7 @@ FloatMatrix::insert (const FloatRowVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) { @@ -369,7 +369,7 @@ FloatMatrix::insert (const FloatColumnVector& a, octave_idx_type r, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) { @@ -493,7 +493,7 @@ } octave_idx_type nc_insert = nc; - FloatMatrix retval (nr, nc + a.length ()); + FloatMatrix retval (nr, nc + a.numel ()); retval.insert (*this, 0, 0); retval.insert (a, 0, nc_insert); return retval; @@ -504,7 +504,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr != a.length ()) + if (nr != a.numel ()) { (*current_liboctave_error_handler) ("row dimension mismatch for append"); return FloatMatrix (); @@ -559,7 +559,7 @@ { octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nc != a.length ()) + if (nc != a.numel ()) { (*current_liboctave_error_handler) ("column dimension mismatch for stack"); @@ -586,7 +586,7 @@ } octave_idx_type nr_insert = nr; - FloatMatrix retval (nr + a.length (), nc); + FloatMatrix retval (nr + a.numel (), nc); retval.insert (*this, 0, 0); retval.insert (a, nr_insert, 0); return retval; @@ -884,7 +884,7 @@ FloatColumnVector sigma = S.extract_diag (); - octave_idx_type r = sigma.length () - 1; + octave_idx_type r = sigma.numel () - 1; octave_idx_type nr = rows (); octave_idx_type nc = cols (); @@ -974,7 +974,7 @@ FloatComplexMatrix FloatMatrix::fourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); const float *in = fortran_vec (); FloatComplexMatrix retval (rows (), cols ()); @@ -986,7 +986,7 @@ FloatComplexMatrix FloatMatrix::ifourier2d (void) const { - dim_vector dv(rows (), cols ()); + dim_vector dv (rows (), cols ()); FloatComplexMatrix retval (*this); FloatComplex *out (retval.fortran_vec ()); @@ -2491,7 +2491,7 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m != b.length ()) + if (m != b.numel ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); else if (m == 0 || n == 0) @@ -2659,11 +2659,11 @@ { FloatMatrix retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); if (len != 0) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); retval = FloatMatrix (len, a_len); float *c = retval.fortran_vec (); @@ -3337,9 +3337,9 @@ { if (n < 1) n = 1; - octave_idx_type m = x1.length (); - - if (x2.length () != m) + octave_idx_type m = x1.numel (); + + if (x2.numel () != m) (*current_liboctave_error_handler) ("linspace: vectors must be of equal length"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fNDArray.cc --- a/liboctave/array/fNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -68,9 +68,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); const float *in (fortran_vec ()); @@ -99,9 +99,9 @@ for (int i = 0; i < dim; i++) stride *= dv(i); - octave_idx_type howmany = numel () / dv (dim); + octave_idx_type howmany = numel () / dv(dim); howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); - octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); + octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride); octave_idx_type dist = (stride == 1 ? n : 1); FloatComplexNDArray retval (*this); @@ -122,7 +122,7 @@ if (dv.length () < 2) return FloatComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); const float *in = fortran_vec (); FloatComplexNDArray retval (dv); FloatComplex *out = retval.fortran_vec (); @@ -142,7 +142,7 @@ if (dv.length () < 2) return FloatComplexNDArray (); - dim_vector dv2(dv(0), dv(1)); + dim_vector dv2 (dv(0), dv(1)); FloatComplexNDArray retval (*this); FloatComplex *out = retval.fortran_vec (); octave_idx_type howmany = numel () / dv(0) / dv(1); @@ -556,7 +556,7 @@ bool FloatNDArray::all_integers (float& max_val, float& min_val) const { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); if (nel > 0) { @@ -843,7 +843,7 @@ std::ostream& operator << (std::ostream& os, const FloatNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); for (octave_idx_type i = 0; i < nel; i++) { @@ -857,7 +857,7 @@ std::istream& operator >> (std::istream& is, FloatNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); if (nel > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/fRowVector.cc --- a/liboctave/array/fRowVector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/fRowVector.cc Sat May 30 05:39:47 2015 -0400 @@ -58,8 +58,8 @@ bool FloatRowVector::operator == (const FloatRowVector& a) const { - octave_idx_type len = length (); - if (len != a.length ()) + octave_idx_type len = numel (); + if (len != a.numel ()) return 0; return mx_inline_equal (len, data (), a.data ()); } @@ -73,9 +73,9 @@ FloatRowVector& FloatRowVector::insert (const FloatRowVector& a, octave_idx_type c) { - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); - if (c < 0 || c + a_len > length ()) + if (c < 0 || c + a_len > numel ()) { (*current_liboctave_error_handler) ("range error for insert"); return *this; @@ -95,7 +95,7 @@ FloatRowVector& FloatRowVector::fill (float val) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -111,7 +111,7 @@ FloatRowVector& FloatRowVector::fill (float val, octave_idx_type c1, octave_idx_type c2) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) { @@ -135,9 +135,9 @@ FloatRowVector FloatRowVector::append (const FloatRowVector& a) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); octave_idx_type nc_insert = len; - FloatRowVector retval (len + a.length ()); + FloatRowVector retval (len + a.numel ()); retval.insert (*this, 0); retval.insert (a, nc_insert); return retval; @@ -194,7 +194,7 @@ { FloatRowVector retval; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); octave_idx_type a_nr = a.rows (); octave_idx_type a_nc = a.cols (); @@ -229,7 +229,7 @@ float FloatRowVector::min (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0; @@ -245,7 +245,7 @@ float FloatRowVector::max (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len == 0) return 0; @@ -263,7 +263,7 @@ { // int field_width = os.precision () + 7; - for (octave_idx_type i = 0; i < a.length (); i++) + for (octave_idx_type i = 0; i < a.numel (); i++) os << " " /* setw (field_width) */ << a.elem (i); return os; } @@ -271,7 +271,7 @@ std::istream& operator >> (std::istream& is, FloatRowVector& a) { - octave_idx_type len = a.length (); + octave_idx_type len = a.numel (); if (len > 0) { @@ -313,9 +313,9 @@ { float retval = 0.0; - octave_idx_type len = v.length (); + octave_idx_type len = v.numel (); - octave_idx_type a_len = a.length (); + octave_idx_type a_len = a.numel (); if (len != a_len) gripe_nonconformant ("operator *", len, a_len); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/idx-vector.cc --- a/liboctave/array/idx-vector.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/idx-vector.cc Sat May 30 05:39:47 2015 -0400 @@ -121,7 +121,7 @@ } idx_vector::idx_range_rep::idx_range_rep (const Range& r) - : start (0), len (r.nelem ()), step (1) + : start (0), len (r.numel ()), step (1) { if (len < 0) { @@ -405,7 +405,7 @@ { octave_idx_type *d = new octave_idx_type [len]; - octave_idx_type ntot = bnda.length (); + octave_idx_type ntot = bnda.numel (); octave_idx_type k = 0; for (octave_idx_type i = 0; i < ntot; i++) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/array/intNDArray.cc --- a/liboctave/array/intNDArray.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/array/intNDArray.cc Sat May 30 05:39:47 2015 -0400 @@ -39,7 +39,7 @@ { boolNDArray b (this->dims ()); - for (octave_idx_type i = 0; i < this->length (); i++) + for (octave_idx_type i = 0; i < this->numel (); i++) b.elem (i) = ! this->elem (i); return b; @@ -49,7 +49,7 @@ bool intNDArray::any_element_not_one_or_zero (void) const { - octave_idx_type nel = this->nelem (); + octave_idx_type nel = this->numel (); for (octave_idx_type i = 0; i < nel; i++) { @@ -143,7 +143,7 @@ std::ostream& operator << (std::ostream& os, const intNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); for (octave_idx_type i = 0; i < nel; i++) os << " " << a.elem (i) << "\n"; @@ -155,7 +155,7 @@ std::istream& operator >> (std::istream& is, intNDArray& a) { - octave_idx_type nel = a.nelem (); + octave_idx_type nel = a.numel (); if (nel > 0) { @@ -183,7 +183,7 @@ intNDArray intNDArray::abs (void) const { - octave_idx_type nel = this->nelem (); + octave_idx_type nel = this->numel (); intNDArray ret (this->dims ()); for (octave_idx_type i = 0; i < nel; i++) @@ -199,7 +199,7 @@ intNDArray intNDArray::signum (void) const { - octave_idx_type nel = this->nelem (); + octave_idx_type nel = this->numel (); intNDArray ret (this->dims ()); for (octave_idx_type i = 0; i < nel; i++) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/cruft/slatec-fn/dpsifn.f --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/cruft/slatec-fn/dpsifn.f Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,368 @@ +*DECK DPSIFN + SUBROUTINE DPSIFN (X, N, KODE, M, ANS, NZ, IERR) +C***BEGIN PROLOGUE DPSIFN +C***PURPOSE Compute derivatives of the Psi function. +C***LIBRARY SLATEC +C***CATEGORY C7C +C***TYPE DOUBLE PRECISION (PSIFN-S, DPSIFN-D) +C***KEYWORDS DERIVATIVES OF THE GAMMA FUNCTION, POLYGAMMA FUNCTION, +C PSI FUNCTION +C***AUTHOR Amos, D. E., (SNLA) +C***DESCRIPTION +C +C The following definitions are used in DPSIFN: +C +C Definition 1 +C PSI(X) = d/dx (ln(GAMMA(X)), the first derivative of +C the log GAMMA function. +C Definition 2 +C K K +C PSI(K,X) = d /dx (PSI(X)), the K-th derivative of PSI(X). +C ___________________________________________________________________ +C DPSIFN computes a sequence of SCALED derivatives of +C the PSI function; i.e. for fixed X and M it computes +C the M-member sequence +C +C ((-1)**(K+1)/GAMMA(K+1))*PSI(K,X) +C for K = N,...,N+M-1 +C +C where PSI(K,X) is as defined above. For KODE=1, DPSIFN returns +C the scaled derivatives as described. KODE=2 is operative only +C when K=0 and in that case DPSIFN returns -PSI(X) + LN(X). That +C is, the logarithmic behavior for large X is removed when KODE=2 +C and K=0. When sums or differences of PSI functions are computed +C the logarithmic terms can be combined analytically and computed +C separately to help retain significant digits. +C +C Note that CALL DPSIFN(X,0,1,1,ANS) results in +C ANS = -PSI(X) +C +C Input X is DOUBLE PRECISION +C X - Argument, X .gt. 0.0D0 +C N - First member of the sequence, 0 .le. N .le. 100 +C N=0 gives ANS(1) = -PSI(X) for KODE=1 +C -PSI(X)+LN(X) for KODE=2 +C KODE - Selection parameter +C KODE=1 returns scaled derivatives of the PSI +C function. +C KODE=2 returns scaled derivatives of the PSI +C function EXCEPT when N=0. In this case, +C ANS(1) = -PSI(X) + LN(X) is returned. +C M - Number of members of the sequence, M.ge.1 +C +C Output ANS is DOUBLE PRECISION +C ANS - A vector of length at least M whose first M +C components contain the sequence of derivatives +C scaled according to KODE. +C NZ - Underflow flag +C NZ.eq.0, A normal return +C NZ.ne.0, Underflow, last NZ components of ANS are +C set to zero, ANS(M-K+1)=0.0, K=1,...,NZ +C IERR - Error flag +C IERR=0, A normal return, computation completed +C IERR=1, Input error, no computation +C IERR=2, Overflow, X too small or N+M-1 too +C large or both +C IERR=3, Error, N too large. Dimensioned +C array TRMR(NMAX) is not large enough for N +C +C The nominal computational accuracy is the maximum of unit +C roundoff (=D1MACH(4)) and 1.0D-18 since critical constants +C are given to only 18 digits. +C +C PSIFN is the single precision version of DPSIFN. +C +C *Long Description: +C +C The basic method of evaluation is the asymptotic expansion +C for large X.ge.XMIN followed by backward recursion on a two +C term recursion relation +C +C W(X+1) + X**(-N-1) = W(X). +C +C This is supplemented by a series +C +C SUM( (X+K)**(-N-1) , K=0,1,2,... ) +C +C which converges rapidly for large N. Both XMIN and the +C number of terms of the series are calculated from the unit +C roundoff of the machine environment. +C +C***REFERENCES Handbook of Mathematical Functions, National Bureau +C of Standards Applied Mathematics Series 55, edited +C by M. Abramowitz and I. A. Stegun, equations 6.3.5, +C 6.3.18, 6.4.6, 6.4.9 and 6.4.10, pp.258-260, 1964. +C D. E. Amos, A portable Fortran subroutine for +C derivatives of the Psi function, Algorithm 610, ACM +C Transactions on Mathematical Software 9, 4 (1983), +C pp. 494-502. +C***ROUTINES CALLED D1MACH, I1MACH +C***REVISION HISTORY (YYMMDD) +C 820601 DATE WRITTEN +C 890531 Changed all specific intrinsics to generic. (WRB) +C 890911 Removed unnecessary intrinsics. (WRB) +C 891006 Cosmetic changes to prologue. (WRB) +C 891006 REVISION DATE from Version 3.2 +C 891214 Prologue converted to Version 4.0 format. (BAB) +C 920501 Reformatted the REFERENCES section. (WRB) +C***END PROLOGUE DPSIFN + INTEGER I, IERR, J, K, KODE, M, MM, MX, N, NMAX, NN, NP, NX, NZ, + * FN + INTEGER I1MACH + DOUBLE PRECISION ANS, ARG, B, DEN, ELIM, EPS, FLN, + * FX, RLN, RXSQ, R1M4, R1M5, S, SLOPE, T, TA, TK, TOL, TOLS, TRM, + * TRMR, TSS, TST, TT, T1, T2, WDTOL, X, XDMLN, XDMY, XINC, XLN, + * XM, XMIN, XQ, YINT + DOUBLE PRECISION D1MACH + DIMENSION B(22), TRM(22), TRMR(100), ANS(*) + SAVE NMAX, B + DATA NMAX /100/ +C----------------------------------------------------------------------- +C BERNOULLI NUMBERS +C----------------------------------------------------------------------- + DATA B(1), B(2), B(3), B(4), B(5), B(6), B(7), B(8), B(9), B(10), + * B(11), B(12), B(13), B(14), B(15), B(16), B(17), B(18), B(19), + * B(20), B(21), B(22) /1.00000000000000000D+00, + * -5.00000000000000000D-01,1.66666666666666667D-01, + * -3.33333333333333333D-02,2.38095238095238095D-02, + * -3.33333333333333333D-02,7.57575757575757576D-02, + * -2.53113553113553114D-01,1.16666666666666667D+00, + * -7.09215686274509804D+00,5.49711779448621554D+01, + * -5.29124242424242424D+02,6.19212318840579710D+03, + * -8.65802531135531136D+04,1.42551716666666667D+06, + * -2.72982310678160920D+07,6.01580873900642368D+08, + * -1.51163157670921569D+10,4.29614643061166667D+11, + * -1.37116552050883328D+13,4.88332318973593167D+14, + * -1.92965793419400681D+16/ +C +C***FIRST EXECUTABLE STATEMENT DPSIFN + IERR = 0 + NZ=0 + IF (X.LE.0.0D0) IERR=1 + IF (N.LT.0) IERR=1 + IF (KODE.LT.1 .OR. KODE.GT.2) IERR=1 + IF (M.LT.1) IERR=1 + IF (IERR.NE.0) RETURN + MM=M + NX = MIN(-I1MACH(15),I1MACH(16)) + R1M5 = D1MACH(5) + R1M4 = D1MACH(4)*0.5D0 + WDTOL = MAX(R1M4,0.5D-18) +C----------------------------------------------------------------------- +C ELIM = APPROXIMATE EXPONENTIAL OVER AND UNDERFLOW LIMIT +C----------------------------------------------------------------------- + ELIM = 2.302D0*(NX*R1M5-3.0D0) + XLN = LOG(X) + 41 CONTINUE + NN = N + MM - 1 + FN = NN + T = (FN+1)*XLN +C----------------------------------------------------------------------- +C OVERFLOW AND UNDERFLOW TEST FOR SMALL AND LARGE X +C----------------------------------------------------------------------- + IF (ABS(T).GT.ELIM) GO TO 290 + IF (X.LT.WDTOL) GO TO 260 +C----------------------------------------------------------------------- +C COMPUTE XMIN AND THE NUMBER OF TERMS OF THE SERIES, FLN+1 +C----------------------------------------------------------------------- + RLN = R1M5*I1MACH(14) + RLN = MIN(RLN,18.06D0) + FLN = MAX(RLN,3.0D0) - 3.0D0 + YINT = 3.50D0 + 0.40D0*FLN + SLOPE = 0.21D0 + FLN*(0.0006038D0*FLN+0.008677D0) + XM = YINT + SLOPE*FN + MX = INT(XM) + 1 + XMIN = MX + IF (N.EQ.0) GO TO 50 + XM = -2.302D0*RLN - MIN(0.0D0,XLN) + ARG = XM/N + ARG = MIN(0.0D0,ARG) + EPS = EXP(ARG) + XM = 1.0D0 - EPS + IF (ABS(ARG).LT.1.0D-3) XM = -ARG + FLN = X*XM/EPS + XM = XMIN - X + IF (XM.GT.7.0D0 .AND. FLN.LT.15.0D0) GO TO 200 + 50 CONTINUE + XDMY = X + XDMLN = XLN + XINC = 0.0D0 + IF (X.GE.XMIN) GO TO 60 + NX = INT(X) + XINC = XMIN - NX + XDMY = X + XINC + XDMLN = LOG(XDMY) + 60 CONTINUE +C----------------------------------------------------------------------- +C GENERATE W(N+MM-1,X) BY THE ASYMPTOTIC EXPANSION +C----------------------------------------------------------------------- + T = FN*XDMLN + T1 = XDMLN + XDMLN + T2 = T + XDMLN + TK = MAX(ABS(T),ABS(T1),ABS(T2)) + IF (TK.GT.ELIM) GO TO 380 + TSS = EXP(-T) + TT = 0.5D0/XDMY + T1 = TT + TST = WDTOL*TT + IF (NN.NE.0) T1 = TT + 1.0D0/FN + RXSQ = 1.0D0/(XDMY*XDMY) + TA = 0.5D0*RXSQ + T = (FN+1)*TA + S = T*B(3) + IF (ABS(S).LT.TST) GO TO 80 + TK = 2.0D0 + DO 70 K=4,22 + T = T*((TK+FN+1)/(TK+1.0D0))*((TK+FN)/(TK+2.0D0))*RXSQ + TRM(K) = T*B(K) + IF (ABS(TRM(K)).LT.TST) GO TO 80 + S = S + TRM(K) + TK = TK + 2.0D0 + 70 CONTINUE + 80 CONTINUE + S = (S+T1)*TSS + IF (XINC.EQ.0.0D0) GO TO 100 +C----------------------------------------------------------------------- +C BACKWARD RECUR FROM XDMY TO X +C----------------------------------------------------------------------- + NX = INT(XINC) + NP = NN + 1 + IF (NX.GT.NMAX) GO TO 390 + IF (NN.EQ.0) GO TO 160 + XM = XINC - 1.0D0 + FX = X + XM +C----------------------------------------------------------------------- +C THIS LOOP SHOULD NOT BE CHANGED. FX IS ACCURATE WHEN X IS SMALL +C----------------------------------------------------------------------- + DO 90 I=1,NX + TRMR(I) = FX**(-NP) + S = S + TRMR(I) + XM = XM - 1.0D0 + FX = X + XM + 90 CONTINUE + 100 CONTINUE + ANS(MM) = S + IF (FN.EQ.0) GO TO 180 +C----------------------------------------------------------------------- +C GENERATE LOWER DERIVATIVES, J.LT.N+MM-1 +C----------------------------------------------------------------------- + IF (MM.EQ.1) RETURN + DO 150 J=2,MM + FN = FN - 1 + TSS = TSS*XDMY + T1 = TT + IF (FN.NE.0) T1 = TT + 1.0D0/FN + T = (FN+1)*TA + S = T*B(3) + IF (ABS(S).LT.TST) GO TO 120 + TK = 4 + FN + DO 110 K=4,22 + TRM(K) = TRM(K)*(FN+1)/TK + IF (ABS(TRM(K)).LT.TST) GO TO 120 + S = S + TRM(K) + TK = TK + 2.0D0 + 110 CONTINUE + 120 CONTINUE + S = (S+T1)*TSS + IF (XINC.EQ.0.0D0) GO TO 140 + IF (FN.EQ.0) GO TO 160 + XM = XINC - 1.0D0 + FX = X + XM + DO 130 I=1,NX + TRMR(I) = TRMR(I)*FX + S = S + TRMR(I) + XM = XM - 1.0D0 + FX = X + XM + 130 CONTINUE + 140 CONTINUE + MX = MM - J + 1 + ANS(MX) = S + IF (FN.EQ.0) GO TO 180 + 150 CONTINUE + RETURN +C----------------------------------------------------------------------- +C RECURSION FOR N = 0 +C----------------------------------------------------------------------- + 160 CONTINUE + DO 170 I=1,NX + S = S + 1.0D0/(X+NX-I) + 170 CONTINUE + 180 CONTINUE + IF (KODE.EQ.2) GO TO 190 + ANS(1) = S - XDMLN + RETURN + 190 CONTINUE + IF (XDMY.EQ.X) RETURN + XQ = XDMY/X + ANS(1) = S - LOG(XQ) + RETURN +C----------------------------------------------------------------------- +C COMPUTE BY SERIES (X+K)**(-(N+1)) , K=0,1,2,... +C----------------------------------------------------------------------- + 200 CONTINUE + NN = INT(FLN) + 1 + NP = N + 1 + T1 = (N+1)*XLN + T = EXP(-T1) + S = T + DEN = X + DO 210 I=1,NN + DEN = DEN + 1.0D0 + TRM(I) = DEN**(-NP) + S = S + TRM(I) + 210 CONTINUE + ANS(1) = S + IF (N.NE.0) GO TO 220 + IF (KODE.EQ.2) ANS(1) = S + XLN + 220 CONTINUE + IF (MM.EQ.1) RETURN +C----------------------------------------------------------------------- +C GENERATE HIGHER DERIVATIVES, J.GT.N +C----------------------------------------------------------------------- + TOL = WDTOL/5.0D0 + DO 250 J=2,MM + T = T/X + S = T + TOLS = T*TOL + DEN = X + DO 230 I=1,NN + DEN = DEN + 1.0D0 + TRM(I) = TRM(I)/DEN + S = S + TRM(I) + IF (TRM(I).LT.TOLS) GO TO 240 + 230 CONTINUE + 240 CONTINUE + ANS(J) = S + 250 CONTINUE + RETURN +C----------------------------------------------------------------------- +C SMALL X.LT.UNIT ROUND OFF +C----------------------------------------------------------------------- + 260 CONTINUE + ANS(1) = X**(-N-1) + IF (MM.EQ.1) GO TO 280 + K = 1 + DO 270 I=2,MM + ANS(K+1) = ANS(K)/X + K = K + 1 + 270 CONTINUE + 280 CONTINUE + IF (N.NE.0) RETURN + IF (KODE.EQ.2) ANS(1) = ANS(1) + XLN + RETURN + 290 CONTINUE + IF (T.GT.0.0D0) GO TO 380 + NZ=0 + IERR=2 + RETURN + 380 CONTINUE + NZ=NZ+1 + ANS(MM)=0.0D0 + MM=MM-1 + IF (MM.EQ.0) RETURN + GO TO 41 + 390 CONTINUE + NZ=0 + IERR=3 + RETURN + END diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/cruft/slatec-fn/module.mk --- a/liboctave/cruft/slatec-fn/module.mk Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/cruft/slatec-fn/module.mk Sat May 30 05:39:47 2015 -0400 @@ -34,6 +34,7 @@ cruft/slatec-fn/dlnrel.f \ cruft/slatec-fn/dpchim.f \ cruft/slatec-fn/dpchst.f \ + cruft/slatec-fn/dpsifn.f \ cruft/slatec-fn/erf.f \ cruft/slatec-fn/gami.f \ cruft/slatec-fn/gamit.f \ @@ -44,6 +45,7 @@ cruft/slatec-fn/inits.f \ cruft/slatec-fn/pchim.f \ cruft/slatec-fn/pchst.f \ + cruft/slatec-fn/psifn.f \ cruft/slatec-fn/r9lgmc.f \ cruft/slatec-fn/r9lgit.f \ cruft/slatec-fn/r9gmit.f \ diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/cruft/slatec-fn/psifn.f --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/cruft/slatec-fn/psifn.f Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,368 @@ +*DECK PSIFN + SUBROUTINE PSIFN (X, N, KODE, M, ANS, NZ, IERR) +C***BEGIN PROLOGUE PSIFN +C***PURPOSE Compute derivatives of the Psi function. +C***LIBRARY SLATEC +C***CATEGORY C7C +C***TYPE SINGLE PRECISION (PSIFN-S, DPSIFN-D) +C***KEYWORDS DERIVATIVES OF THE GAMMA FUNCTION, POLYGAMMA FUNCTION, +C PSI FUNCTION +C***AUTHOR Amos, D. E., (SNLA) +C***DESCRIPTION +C +C The following definitions are used in PSIFN: +C +C Definition 1 +C PSI(X) = d/dx (ln(GAMMA(X)), the first derivative of +C the LOG GAMMA function. +C Definition 2 +C K K +C PSI(K,X) = d /dx (PSI(X)), the K-th derivative of PSI(X). +C ___________________________________________________________________ +C PSIFN computes a sequence of SCALED derivatives of +C the PSI function; i.e. for fixed X and M it computes +C the M-member sequence +C +C ((-1)**(K+1)/GAMMA(K+1))*PSI(K,X) +C for K = N,...,N+M-1 +C +C where PSI(K,X) is as defined above. For KODE=1, PSIFN returns +C the scaled derivatives as described. KODE=2 is operative only +C when K=0 and in that case PSIFN returns -PSI(X) + LN(X). That +C is, the logarithmic behavior for large X is removed when KODE=1 +C and K=0. When sums or differences of PSI functions are computed +C the logarithmic terms can be combined analytically and computed +C separately to help retain significant digits. +C +C Note that CALL PSIFN(X,0,1,1,ANS) results in +C ANS = -PSI(X) +C +C Input +C X - Argument, X .gt. 0.0E0 +C N - First member of the sequence, 0 .le. N .le. 100 +C N=0 gives ANS(1) = -PSI(X) for KODE=1 +C -PSI(X)+LN(X) for KODE=2 +C KODE - Selection parameter +C KODE=1 returns scaled derivatives of the PSI +C function. +C KODE=2 returns scaled derivatives of the PSI +C function EXCEPT when N=0. In this case, +C ANS(1) = -PSI(X) + LN(X) is returned. +C M - Number of members of the sequence, M .ge. 1 +C +C Output +C ANS - A vector of length at least M whose first M +C components contain the sequence of derivatives +C scaled according to KODE. +C NZ - Underflow flag +C NZ.eq.0, A normal return +C NZ.ne.0, Underflow, last NZ components of ANS are +C set to zero, ANS(M-K+1)=0.0, K=1,...,NZ +C IERR - Error flag +C IERR=0, A normal return, computation completed +C IERR=1, Input error, no computation +C IERR=2, Overflow, X too small or N+M-1 too +C large or both +C IERR=3, Error, N too large. Dimensioned +C array TRMR(NMAX) is not large enough for N +C +C The nominal computational accuracy is the maximum of unit +C roundoff (=R1MACH(4)) and 1.0E-18 since critical constants +C are given to only 18 digits. +C +C DPSIFN is the Double Precision version of PSIFN. +C +C *Long Description: +C +C The basic method of evaluation is the asymptotic expansion +C for large X.ge.XMIN followed by backward recursion on a two +C term recursion relation +C +C W(X+1) + X**(-N-1) = W(X). +C +C This is supplemented by a series +C +C SUM( (X+K)**(-N-1) , K=0,1,2,... ) +C +C which converges rapidly for large N. Both XMIN and the +C number of terms of the series are calculated from the unit +C roundoff of the machine environment. +C +C***REFERENCES Handbook of Mathematical Functions, National Bureau +C of Standards Applied Mathematics Series 55, edited +C by M. Abramowitz and I. A. Stegun, equations 6.3.5, +C 6.3.18, 6.4.6, 6.4.9 and 6.4.10, pp.258-260, 1964. +C D. E. Amos, A portable Fortran subroutine for +C derivatives of the Psi function, Algorithm 610, ACM +C Transactions on Mathematical Software 9, 4 (1983), +C pp. 494-502. +C***ROUTINES CALLED I1MACH, R1MACH +C***REVISION HISTORY (YYMMDD) +C 820601 DATE WRITTEN +C 890531 Changed all specific intrinsics to generic. (WRB) +C 890531 REVISION DATE from Version 3.2 +C 891214 Prologue converted to Version 4.0 format. (BAB) +C 920501 Reformatted the REFERENCES section. (WRB) +C***END PROLOGUE PSIFN + INTEGER I, IERR, J, K, KODE, M, MM, MX, N, NMAX, NN, NP, NX, NZ + INTEGER I1MACH + REAL ANS, ARG, B, DEN, ELIM, EPS, FLN, FN, FNP, FNS, FX, RLN, + * RXSQ, R1M4, R1M5, S, SLOPE, T, TA, TK, TOL, TOLS, TRM, TRMR, + * TSS, TST, TT, T1, T2, WDTOL, X, XDMLN, XDMY, XINC, XLN, XM, + * XMIN, XQ, YINT + REAL R1MACH + DIMENSION B(22), TRM(22), TRMR(100), ANS(*) + SAVE NMAX, B + DATA NMAX /100/ +C----------------------------------------------------------------------- +C BERNOULLI NUMBERS +C----------------------------------------------------------------------- + DATA B(1), B(2), B(3), B(4), B(5), B(6), B(7), B(8), B(9), B(10), + * B(11), B(12), B(13), B(14), B(15), B(16), B(17), B(18), B(19), + * B(20), B(21), B(22) /1.00000000000000000E+00, + * -5.00000000000000000E-01,1.66666666666666667E-01, + * -3.33333333333333333E-02,2.38095238095238095E-02, + * -3.33333333333333333E-02,7.57575757575757576E-02, + * -2.53113553113553114E-01,1.16666666666666667E+00, + * -7.09215686274509804E+00,5.49711779448621554E+01, + * -5.29124242424242424E+02,6.19212318840579710E+03, + * -8.65802531135531136E+04,1.42551716666666667E+06, + * -2.72982310678160920E+07,6.01580873900642368E+08, + * -1.51163157670921569E+10,4.29614643061166667E+11, + * -1.37116552050883328E+13,4.88332318973593167E+14, + * -1.92965793419400681E+16/ +C +C***FIRST EXECUTABLE STATEMENT PSIFN + IERR = 0 + NZ=0 + IF (X.LE.0.0E0) IERR=1 + IF (N.LT.0) IERR=1 + IF (KODE.LT.1 .OR. KODE.GT.2) IERR=1 + IF (M.LT.1) IERR=1 + IF (IERR.NE.0) RETURN + MM=M + NX = MIN(-I1MACH(12),I1MACH(13)) + R1M5 = R1MACH(5) + R1M4 = R1MACH(4)*0.5E0 + WDTOL = MAX(R1M4,0.5E-18) +C----------------------------------------------------------------------- +C ELIM = APPROXIMATE EXPONENTIAL OVER AND UNDERFLOW LIMIT +C----------------------------------------------------------------------- + ELIM = 2.302E0*(NX*R1M5-3.0E0) + XLN = LOG(X) + 41 CONTINUE + NN = N + MM - 1 + FN = NN + FNP = FN + 1.0E0 + T = FNP*XLN +C----------------------------------------------------------------------- +C OVERFLOW AND UNDERFLOW TEST FOR SMALL AND LARGE X +C----------------------------------------------------------------------- + IF (ABS(T).GT.ELIM) GO TO 290 + IF (X.LT.WDTOL) GO TO 260 +C----------------------------------------------------------------------- +C COMPUTE XMIN AND THE NUMBER OF TERMS OF THE SERIES, FLN+1 +C----------------------------------------------------------------------- + RLN = R1M5*I1MACH(11) + RLN = MIN(RLN,18.06E0) + FLN = MAX(RLN,3.0E0) - 3.0E0 + YINT = 3.50E0 + 0.40E0*FLN + SLOPE = 0.21E0 + FLN*(0.0006038E0*FLN+0.008677E0) + XM = YINT + SLOPE*FN + MX = INT(XM) + 1 + XMIN = MX + IF (N.EQ.0) GO TO 50 + XM = -2.302E0*RLN - MIN(0.0E0,XLN) + FNS = N + ARG = XM/FNS + ARG = MIN(0.0E0,ARG) + EPS = EXP(ARG) + XM = 1.0E0 - EPS + IF (ABS(ARG).LT.1.0E-3) XM = -ARG + FLN = X*XM/EPS + XM = XMIN - X + IF (XM.GT.7.0E0 .AND. FLN.LT.15.0E0) GO TO 200 + 50 CONTINUE + XDMY = X + XDMLN = XLN + XINC = 0.0E0 + IF (X.GE.XMIN) GO TO 60 + NX = INT(X) + XINC = XMIN - NX + XDMY = X + XINC + XDMLN = LOG(XDMY) + 60 CONTINUE +C----------------------------------------------------------------------- +C GENERATE W(N+MM-1,X) BY THE ASYMPTOTIC EXPANSION +C----------------------------------------------------------------------- + T = FN*XDMLN + T1 = XDMLN + XDMLN + T2 = T + XDMLN + TK = MAX(ABS(T),ABS(T1),ABS(T2)) + IF (TK.GT.ELIM) GO TO 380 + TSS = EXP(-T) + TT = 0.5E0/XDMY + T1 = TT + TST = WDTOL*TT + IF (NN.NE.0) T1 = TT + 1.0E0/FN + RXSQ = 1.0E0/(XDMY*XDMY) + TA = 0.5E0*RXSQ + T = FNP*TA + S = T*B(3) + IF (ABS(S).LT.TST) GO TO 80 + TK = 2.0E0 + DO 70 K=4,22 + T = T*((TK+FN+1.0E0)/(TK+1.0E0))*((TK+FN)/(TK+2.0E0))*RXSQ + TRM(K) = T*B(K) + IF (ABS(TRM(K)).LT.TST) GO TO 80 + S = S + TRM(K) + TK = TK + 2.0E0 + 70 CONTINUE + 80 CONTINUE + S = (S+T1)*TSS + IF (XINC.EQ.0.0E0) GO TO 100 +C----------------------------------------------------------------------- +C BACKWARD RECUR FROM XDMY TO X +C----------------------------------------------------------------------- + NX = INT(XINC) + NP = NN + 1 + IF (NX.GT.NMAX) GO TO 390 + IF (NN.EQ.0) GO TO 160 + XM = XINC - 1.0E0 + FX = X + XM +C----------------------------------------------------------------------- +C THIS LOOP SHOULD NOT BE CHANGED. FX IS ACCURATE WHEN X IS SMALL +C----------------------------------------------------------------------- + DO 90 I=1,NX + TRMR(I) = FX**(-NP) + S = S + TRMR(I) + XM = XM - 1.0E0 + FX = X + XM + 90 CONTINUE + 100 CONTINUE + ANS(MM) = S + IF (FN.EQ.0.0E0) GO TO 180 +C----------------------------------------------------------------------- +C GENERATE LOWER DERIVATIVES, J.LT.N+MM-1 +C----------------------------------------------------------------------- + IF (MM.EQ.1) RETURN + DO 150 J=2,MM + FNP = FN + FN = FN - 1.0E0 + TSS = TSS*XDMY + T1 = TT + IF (FN.NE.0.0E0) T1 = TT + 1.0E0/FN + T = FNP*TA + S = T*B(3) + IF (ABS(S).LT.TST) GO TO 120 + TK = 3.0E0 + FNP + DO 110 K=4,22 + TRM(K) = TRM(K)*FNP/TK + IF (ABS(TRM(K)).LT.TST) GO TO 120 + S = S + TRM(K) + TK = TK + 2.0E0 + 110 CONTINUE + 120 CONTINUE + S = (S+T1)*TSS + IF (XINC.EQ.0.0E0) GO TO 140 + IF (FN.EQ.0.0E0) GO TO 160 + XM = XINC - 1.0E0 + FX = X + XM + DO 130 I=1,NX + TRMR(I) = TRMR(I)*FX + S = S + TRMR(I) + XM = XM - 1.0E0 + FX = X + XM + 130 CONTINUE + 140 CONTINUE + MX = MM - J + 1 + ANS(MX) = S + IF (FN.EQ.0.0E0) GO TO 180 + 150 CONTINUE + RETURN +C----------------------------------------------------------------------- +C RECURSION FOR N = 0 +C----------------------------------------------------------------------- + 160 CONTINUE + DO 170 I=1,NX + S = S + 1.0E0/(X+NX-I) + 170 CONTINUE + 180 CONTINUE + IF (KODE.EQ.2) GO TO 190 + ANS(1) = S - XDMLN + RETURN + 190 CONTINUE + IF (XDMY.EQ.X) RETURN + XQ = XDMY/X + ANS(1) = S - LOG(XQ) + RETURN +C----------------------------------------------------------------------- +C COMPUTE BY SERIES (X+K)**(-(N+1)) , K=0,1,2,... +C----------------------------------------------------------------------- + 200 CONTINUE + NN = INT(FLN) + 1 + NP = N + 1 + T1 = (FNS+1.0E0)*XLN + T = EXP(-T1) + S = T + DEN = X + DO 210 I=1,NN + DEN = DEN + 1.0E0 + TRM(I) = DEN**(-NP) + S = S + TRM(I) + 210 CONTINUE + ANS(1) = S + IF (N.NE.0) GO TO 220 + IF (KODE.EQ.2) ANS(1) = S + XLN + 220 CONTINUE + IF (MM.EQ.1) RETURN +C----------------------------------------------------------------------- +C GENERATE HIGHER DERIVATIVES, J.GT.N +C----------------------------------------------------------------------- + TOL = WDTOL/5.0E0 + DO 250 J=2,MM + T = T/X + S = T + TOLS = T*TOL + DEN = X + DO 230 I=1,NN + DEN = DEN + 1.0E0 + TRM(I) = TRM(I)/DEN + S = S + TRM(I) + IF (TRM(I).LT.TOLS) GO TO 240 + 230 CONTINUE + 240 CONTINUE + ANS(J) = S + 250 CONTINUE + RETURN +C----------------------------------------------------------------------- +C SMALL X.LT.UNIT ROUND OFF +C----------------------------------------------------------------------- + 260 CONTINUE + ANS(1) = X**(-N-1) + IF (MM.EQ.1) GO TO 280 + K = 1 + DO 270 I=2,MM + ANS(K+1) = ANS(K)/X + K = K + 1 + 270 CONTINUE + 280 CONTINUE + IF (N.NE.0) RETURN + IF (KODE.EQ.2) ANS(1) = ANS(1) + XLN + RETURN + 290 CONTINUE + IF (T.GT.0.0E0) GO TO 380 + NZ=0 + IERR=2 + RETURN + 380 CONTINUE + NZ=NZ+1 + ANS(MM)=0.0E0 + MM=MM-1 + IF(MM.EQ.0) RETURN + GO TO 41 + 390 CONTINUE + IERR=3 + NZ=0 + RETURN + END diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/CmplxCHOL.cc --- a/liboctave/numeric/CmplxCHOL.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/CmplxCHOL.cc Sat May 30 05:39:47 2015 -0400 @@ -200,7 +200,7 @@ { octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { ComplexColumnVector utmp = u; @@ -220,7 +220,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { ComplexColumnVector utmp = u; @@ -242,7 +242,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); @@ -305,7 +305,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { init (chol_mat.hermitian () * chol_mat + ComplexMatrix (u) * ComplexMatrix (u).hermitian (), false); @@ -331,7 +331,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { if (singular (chol_mat)) info = 2; @@ -358,7 +358,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/CmplxLU.cc --- a/liboctave/numeric/CmplxLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/CmplxLU.cc Sat May 30 05:39:47 2015 -0400 @@ -98,7 +98,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ComplexColumnVector utmp = u; ComplexColumnVector vtmp = v; @@ -149,7 +149,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ComplexColumnVector utmp = u; ComplexColumnVector vtmp = v; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/CmplxQR.cc --- a/liboctave/numeric/CmplxQR.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/CmplxQR.cc Sat May 30 05:39:47 2015 -0400 @@ -212,7 +212,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ComplexColumnVector utmp = u; ComplexColumnVector vtmp = v; @@ -259,7 +259,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -292,14 +292,14 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -317,7 +317,7 @@ } OCTAVE_LOCAL_BUFFER (double, rw, kmax); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; ComplexColumnVector utmp = u.column (jsi(i)); @@ -365,7 +365,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -377,7 +377,7 @@ else if (nj > 0) { OCTAVE_LOCAL_BUFFER (double, rw, k); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; F77_XFCN (zqrdec, ZQRDEC, (m, n - ii, k == m ? k : k - ii, @@ -405,7 +405,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = std::min (m, n); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -477,7 +477,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { init (q*r + ComplexMatrix (u) * ComplexMatrix (v).hermitian (), get_type ()); @@ -573,7 +573,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -593,21 +593,21 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); else if (nj > 0) { ComplexMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::insert_col (a, js(i), u.column (i)); init (a, get_type ()); } @@ -637,7 +637,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -649,7 +649,7 @@ else if (nj > 0) { ComplexMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::delete_col (a, js(i)); init (a, get_type ()); } @@ -663,7 +663,7 @@ octave_idx_type m = r.rows (); octave_idx_type n = r.columns (); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/CollocWt.cc --- a/liboctave/numeric/CollocWt.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/CollocWt.cc Sat May 30 05:39:47 2015 -0400 @@ -175,9 +175,9 @@ dif2[i] = (ab + ap + z1) / z / z / (z + 1.0); else { - z = z * z; + z *= z; double y = z1 * (ab + z1); - y = y * (ap + y); + y *= (ap + y); dif2[i] = y / z / (z - 1.0); } } @@ -218,11 +218,11 @@ if (i != 0) { for (octave_idx_type j = 1; j <= i; j++) - zc = zc - z / (x - root[j-1]); + zc -= z / (x - root[j-1]); } - z = z / zc; - x = x - z; + z /= zc; + x -= z; // Famous last words: 100 iterations should be more than // enough in all cases. @@ -235,7 +235,7 @@ } root[i] = x; - x = x + sqrt (std::numeric_limits::epsilon ()); + x += sqrt (std::numeric_limits::epsilon ()); } // Add interpolation points at x = 0 and/or x = 1. @@ -362,7 +362,7 @@ vect[j] = ax / (dif1[j] * dif1[j]); - y = y + vect[j]; + y += vect[j]; } for (octave_idx_type j = 0; j < nt; j++) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/DASPK.cc --- a/liboctave/numeric/DASPK.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/DASPK.cc Sat May 30 05:39:47 2015 -0400 @@ -91,7 +91,7 @@ if (ires >= 0) { - if (tmp_delta.length () == 0) + if (tmp_delta.numel () == 0) ires = -2; else { @@ -196,7 +196,7 @@ ColumnVector res = (*user_fun) (x, xdot, t, ires); - if (res.length () != x.length ()) + if (res.numel () != x.numel ()) { (*current_liboctave_error_handler) ("daspk: inconsistent sizes for state and residual vectors"); @@ -240,8 +240,8 @@ abs_tol = absolute_tolerance (); rel_tol = relative_tolerance (); - octave_idx_type abs_tol_len = abs_tol.length (); - octave_idx_type rel_tol_len = rel_tol.length (); + octave_idx_type abs_tol_len = abs_tol.numel (); + octave_idx_type rel_tol_len = rel_tol.numel (); if (abs_tol_len == 1 && rel_tol_len == 1) { @@ -302,7 +302,7 @@ { Array ict = inequality_constraint_types (); - if (ict.length () == n) + if (ict.numel () == n) { for (octave_idx_type i = 0; i < n; i++) { @@ -347,7 +347,7 @@ Array av = algebraic_variables (); - if (av.length () == n) + if (av.numel () == n) { octave_idx_type lid; if (eiq == 0 || eiq == 2) @@ -387,7 +387,7 @@ Array av = algebraic_variables (); - if (av.length () == n) + if (av.numel () == n) { octave_idx_type lid; if (eiq == 0 || eiq == 2) @@ -406,7 +406,7 @@ { Array ich = initial_condition_heuristics (); - if (ich.length () == 6) + if (ich.numel () == 6) { iwork(31) = NINTbig (ich(0)); iwork(32) = NINTbig (ich(1)); @@ -538,7 +538,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -583,7 +583,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -597,7 +597,7 @@ xdot_out.elem (0, i) = xdot.elem (i); } - octave_idx_type n_crit = tcrit.capacity (); + octave_idx_type n_crit = tcrit.numel (); if (n_crit > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/DASRT.cc --- a/liboctave/numeric/DASRT.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/DASRT.cc Sat May 30 05:39:47 2015 -0400 @@ -87,7 +87,7 @@ ColumnVector tmp_fval = (*user_fsub) (tmp_state, tmp_deriv, t, ires); - if (tmp_fval.length () == 0) + if (tmp_fval.numel () == 0) ires = -2; else { @@ -182,7 +182,7 @@ if (user_csub) { ColumnVector tmp = (*user_csub) (x, t); - ng = tmp.length (); + ng = tmp.numel (); } else ng = 0; @@ -233,7 +233,7 @@ ColumnVector fval = (*user_fsub) (x, xdot, t, ires); - if (fval.length () != x.length ()) + if (fval.numel () != x.numel ()) { (*current_liboctave_error_handler) ("dasrt: inconsistent sizes for state and residual vectors"); @@ -290,8 +290,8 @@ abs_tol = absolute_tolerance (); rel_tol = relative_tolerance (); - octave_idx_type abs_tol_len = abs_tol.length (); - octave_idx_type rel_tol_len = rel_tol.length (); + octave_idx_type abs_tol_len = abs_tol.numel (); + octave_idx_type rel_tol_len = rel_tol.numel (); if (abs_tol_len == 1 && rel_tol_len == 1) { @@ -393,7 +393,7 @@ Matrix xdot_out; ColumnVector t_out = tout; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -452,7 +452,7 @@ Matrix xdot_out; ColumnVector t_outs = tout; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -460,7 +460,7 @@ x_out.resize (n_out, n); xdot_out.resize (n_out, n); - octave_idx_type n_crit = tcrit.capacity (); + octave_idx_type n_crit = tcrit.numel (); if (n_crit > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/DASSL.cc --- a/liboctave/numeric/DASSL.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/DASSL.cc Sat May 30 05:39:47 2015 -0400 @@ -84,7 +84,7 @@ if (ires >= 0) { - if (tmp_delta.length () == 0) + if (tmp_delta.numel () == 0) ires = -2; else { @@ -175,7 +175,7 @@ ColumnVector res = (*user_fun) (x, xdot, t, ires); - if (res.length () != x.length ()) + if (res.numel () != x.numel ()) { (*current_liboctave_error_handler) ("dassl: inconsistent sizes for state and residual vectors"); @@ -251,8 +251,8 @@ abs_tol = absolute_tolerance (); rel_tol = relative_tolerance (); - octave_idx_type abs_tol_len = abs_tol.length (); - octave_idx_type rel_tol_len = rel_tol.length (); + octave_idx_type abs_tol_len = abs_tol.numel (); + octave_idx_type rel_tol_len = rel_tol.numel (); if (abs_tol_len == 1 && rel_tol_len == 1) { @@ -353,7 +353,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -398,7 +398,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -412,7 +412,7 @@ xdot_out.elem (0, i) = xdot.elem (i); } - octave_idx_type n_crit = tcrit.capacity (); + octave_idx_type n_crit = tcrit.numel (); if (n_crit > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/LSODE.cc --- a/liboctave/numeric/LSODE.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/LSODE.cc Sat May 30 05:39:47 2015 -0400 @@ -74,7 +74,7 @@ tmp_deriv = (*user_fun) (*tmp_x, time); - if (tmp_deriv.length () == 0) + if (tmp_deriv.numel () == 0) ierr = -1; else { @@ -208,7 +208,7 @@ ColumnVector xdot = (*user_fun) (x, t); - if (x.length () != xdot.length ()) + if (x.numel () != xdot.numel ()) { (*current_liboctave_error_handler) ("lsode: inconsistent sizes for state and derivative vectors"); @@ -224,7 +224,7 @@ rel_tol = relative_tolerance (); abs_tol = absolute_tolerance (); - octave_idx_type abs_tol_len = abs_tol.length (); + octave_idx_type abs_tol_len = abs_tol.numel (); if (abs_tol_len == 1) itol = 1; @@ -383,7 +383,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -413,7 +413,7 @@ { Matrix retval; - octave_idx_type n_out = tout.capacity (); + octave_idx_type n_out = tout.numel (); octave_idx_type n = size (); if (n_out > 0 && n > 0) @@ -423,7 +423,7 @@ for (octave_idx_type i = 0; i < n; i++) retval.elem (0, i) = x.elem (i); - octave_idx_type n_crit = tcrit.capacity (); + octave_idx_type n_crit = tcrit.numel (); if (n_crit > 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/ODES.cc --- a/liboctave/numeric/ODES.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/ODES.cc Sat May 30 05:39:47 2015 -0400 @@ -31,7 +31,7 @@ ODES::initialize (const ColumnVector& xx, double tt) { base_diff_eqn::initialize (xx, tt); - xdot = ColumnVector (xx.length (), 0.0); + xdot = ColumnVector (xx.numel (), 0.0); } void @@ -39,6 +39,6 @@ const ColumnVector& xtheta) { base_diff_eqn::initialize (xx, tt); - xdot = ColumnVector (xx.length (), 0.0); + xdot = ColumnVector (xx.numel (), 0.0); theta = xtheta; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/ODES.h --- a/liboctave/numeric/ODES.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/ODES.h Sat May 30 05:39:47 2015 -0400 @@ -35,11 +35,11 @@ : base_diff_eqn (), ODESFunc (), xdot (), theta () { } ODES (const ColumnVector& s, double tm, ODESFunc& f) - : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.length (), 0.0), theta () { } + : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.numel (), 0.0), theta () { } ODES (const ColumnVector& s, const ColumnVector& xtheta, double tm, ODESFunc& f) - : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.length (), 0.0), + : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.numel (), 0.0), theta (xtheta) { } ODES (const ODES& a) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/Quad.cc --- a/liboctave/numeric/Quad.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/Quad.cc Sat May 30 05:39:47 2015 -0400 @@ -126,7 +126,7 @@ DefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr) { - octave_idx_type npts = singularities.capacity () + 2; + octave_idx_type npts = singularities.numel () + 2; double *points = singularities.fortran_vec (); double result = 0.0; @@ -224,7 +224,7 @@ FloatDefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr) { - octave_idx_type npts = singularities.capacity () + 2; + octave_idx_type npts = singularities.numel () + 2; float *points = singularities.fortran_vec (); float result = 0.0; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/SparseCmplxLU.cc --- a/liboctave/numeric/SparseCmplxLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/SparseCmplxLU.cc Sat May 30 05:39:47 2015 -0400 @@ -58,7 +58,7 @@ double tmp = octave_sparse_params::get_key ("spumoni"); if (!xisnan (tmp)) Control (UMFPACK_PRL) = tmp; - if (piv_thres.nelem () == 2) + if (piv_thres.numel () == 2) { tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0)); if (!xisnan (tmp)) @@ -267,7 +267,7 @@ double tmp = octave_sparse_params::get_key ("spumoni"); if (!xisnan (tmp)) Control (UMFPACK_PRL) = tmp; - if (piv_thres.nelem () == 2) + if (piv_thres.numel () == 2) { tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0)); if (!xisnan (tmp)) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/SparsedbleLU.cc --- a/liboctave/numeric/SparsedbleLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/SparsedbleLU.cc Sat May 30 05:39:47 2015 -0400 @@ -57,7 +57,7 @@ if (!xisnan (tmp)) Control (UMFPACK_PRL) = tmp; - if (piv_thres.nelem () == 2) + if (piv_thres.numel () == 2) { tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0)); if (!xisnan (tmp)) @@ -253,7 +253,7 @@ if (!xisnan (tmp)) Control (UMFPACK_PRL) = tmp; - if (piv_thres.nelem () == 2) + if (piv_thres.numel () == 2) { tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0)); if (!xisnan (tmp)) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/base-dae.h --- a/liboctave/numeric/base-dae.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/base-dae.h Sat May 30 05:39:47 2015 -0400 @@ -34,7 +34,7 @@ : base_diff_eqn (), xdot () { } base_diff_alg_eqn (const ColumnVector& xx, double tt) - : base_diff_eqn (xx, tt), xdot (xx.length (), 0.0) { } + : base_diff_eqn (xx, tt), xdot (xx.numel (), 0.0) { } base_diff_alg_eqn (const ColumnVector& xx, const ColumnVector& xxdot, double tt) @@ -58,7 +58,7 @@ void initialize (const ColumnVector& x0, double t0) { base_diff_eqn::initialize (x0, t0); - xdot = ColumnVector (x0.length (), 0.0); + xdot = ColumnVector (x0.numel (), 0.0); } void initialize (const ColumnVector& x0, const ColumnVector& xdot0, diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/base-de.h --- a/liboctave/numeric/base-de.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/base-de.h Sat May 30 05:39:47 2015 -0400 @@ -72,7 +72,7 @@ force_restart (); } - octave_idx_type size (void) const { return x.capacity (); } + octave_idx_type size (void) const { return x.numel (); } ColumnVector state (void) const { return x; } diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/base-lu.cc --- a/liboctave/numeric/base-lu.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/base-lu.cc Sat May 30 05:39:47 2015 -0400 @@ -129,7 +129,7 @@ for (octave_idx_type i = 0; i < a_nr; i++) pvt.xelem (i) = i; - for (octave_idx_type i = 0; i < ipvt.length (); i++) + for (octave_idx_type i = 0; i < ipvt.numel (); i++) { octave_idx_type k = ipvt.xelem (i); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/base-min.h --- a/liboctave/numeric/base-min.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/base-min.h Sat May 30 05:39:47 2015 -0400 @@ -114,7 +114,7 @@ return do_minimize (objf, inform, lambda); } - octave_idx_type size (void) const { return x.capacity (); } + octave_idx_type size (void) const { return x.numel (); } protected: diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/dbleCHOL.cc --- a/liboctave/numeric/dbleCHOL.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/dbleCHOL.cc Sat May 30 05:39:47 2015 -0400 @@ -205,7 +205,7 @@ { octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { ColumnVector utmp = u; @@ -225,7 +225,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { ColumnVector utmp = u; @@ -247,7 +247,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); @@ -309,7 +309,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { init (chol_mat.transpose () * chol_mat + Matrix (u) * Matrix (u).transpose (), false); @@ -335,7 +335,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { if (singular (chol_mat)) info = 2; @@ -361,7 +361,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/dbleLU.cc --- a/liboctave/numeric/dbleLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/dbleLU.cc Sat May 30 05:39:47 2015 -0400 @@ -97,7 +97,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ColumnVector utmp = u; ColumnVector vtmp = v; @@ -147,7 +147,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ColumnVector utmp = u; ColumnVector vtmp = v; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/dbleQR.cc --- a/liboctave/numeric/dbleQR.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/dbleQR.cc Sat May 30 05:39:47 2015 -0400 @@ -213,7 +213,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { ColumnVector utmp = u; ColumnVector vtmp = v; @@ -257,7 +257,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -290,14 +290,14 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -315,7 +315,7 @@ } OCTAVE_LOCAL_BUFFER (double, w, kmax); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; ColumnVector utmp = u.column (jsi(i)); @@ -363,7 +363,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -375,7 +375,7 @@ else if (nj > 0) { OCTAVE_LOCAL_BUFFER (double, w, k); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; F77_XFCN (dqrdec, DQRDEC, (m, n - ii, k == m ? k : k - ii, @@ -403,7 +403,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = std::min (m, n); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -473,7 +473,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { init (q*r + Matrix (u) * Matrix (v).transpose (), get_type ()); } @@ -568,7 +568,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -588,21 +588,21 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); else if (nj > 0) { Matrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::insert_col (a, js(i), u.column (i)); init (a, get_type ()); } @@ -632,7 +632,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -644,7 +644,7 @@ else if (nj > 0) { Matrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::delete_col (a, js(i)); init (a, get_type ()); } @@ -658,7 +658,7 @@ octave_idx_type m = r.rows (); octave_idx_type n = r.columns (); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/eigs-base.cc --- a/liboctave/numeric/eigs-base.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/eigs-base.cc Sat May 30 05:39:47 2015 -0400 @@ -445,7 +445,7 @@ { if (cholB) { - if (permB.length ()) + if (permB.numel ()) { SparseMatrix tmp(n,n,n); for (octave_idx_type i = 0; i < n; i++) @@ -457,15 +457,14 @@ } tmp.xcidx (n) = n; - AminusSigmaB = AminusSigmaB - sigma * tmp * - b.transpose () * b * tmp.transpose (); + AminusSigmaB -= sigma * tmp * + b.transpose () * b * tmp.transpose (); } else - AminusSigmaB = AminusSigmaB - sigma * - b.transpose () * b; + AminusSigmaB -= sigma * b.transpose () * b; } else - AminusSigmaB = AminusSigmaB - sigma * b; + AminusSigmaB -= sigma * b; } else { @@ -480,7 +479,7 @@ sigmat.xcidx (i+1) = i + 1; } - AminusSigmaB = AminusSigmaB - sigmat; + AminusSigmaB -= sigmat; } SparseLU fact (AminusSigmaB); @@ -542,7 +541,7 @@ const double *pB = permB.fortran_vec (); double *p = AminusSigmaB.fortran_vec (); - if (permB.length ()) + if (permB.numel ()) { for (octave_idx_type j = 0; j < b.cols (); j++) @@ -552,10 +551,10 @@ static_cast(pB[j])); } else - AminusSigmaB = AminusSigmaB - tmp; + AminusSigmaB -= tmp; } else - AminusSigmaB = AminusSigmaB - sigma * b; + AminusSigmaB -= sigma * b; } else { @@ -610,7 +609,7 @@ { if (cholB) { - if (permB.length ()) + if (permB.numel ()) { SparseMatrix tmp(n,n,n); for (octave_idx_type i = 0; i < n; i++) @@ -622,14 +621,14 @@ } tmp.xcidx (n) = n; - AminusSigmaB = AminusSigmaB - tmp * b.hermitian () * b * - tmp.transpose () * sigma; + AminusSigmaB -= tmp * b.hermitian () * b * + tmp.transpose () * sigma; } else - AminusSigmaB = AminusSigmaB - sigma * b.hermitian () * b; + AminusSigmaB -= sigma * b.hermitian () * b; } else - AminusSigmaB = AminusSigmaB - sigma * b; + AminusSigmaB -= sigma * b; } else { @@ -644,7 +643,7 @@ sigmat.xcidx (i+1) = i + 1; } - AminusSigmaB = AminusSigmaB - sigmat; + AminusSigmaB -= sigmat; } SparseComplexLU fact (AminusSigmaB); @@ -706,7 +705,7 @@ const double *pB = permB.fortran_vec (); Complex *p = AminusSigmaB.fortran_vec (); - if (permB.length ()) + if (permB.numel ()) { for (octave_idx_type j = 0; j < b.cols (); j++) @@ -716,10 +715,10 @@ static_cast(pB[j])); } else - AminusSigmaB = AminusSigmaB - tmp; + AminusSigmaB -= tmp; } else - AminusSigmaB = AminusSigmaB - sigma * b; + AminusSigmaB -= sigma * b; } else { @@ -830,10 +829,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check the we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); @@ -881,7 +880,7 @@ { bt = b; b = b.transpose (); - if (permB.length () == 0) + if (permB.numel () == 0) { permB = ColumnVector (n); for (octave_idx_type i = 0; i < n; i++) @@ -1154,10 +1153,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check the we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); return -1; @@ -1744,10 +1743,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check the we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); @@ -1795,7 +1794,7 @@ { bt = b; b = b.transpose (); - if (permB.length () == 0) + if (permB.numel () == 0) { permB = ColumnVector (n); for (octave_idx_type i = 0; i < n; i++) @@ -2117,10 +2116,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check that we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); return -1; @@ -2812,10 +2811,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check the we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); @@ -2863,7 +2862,7 @@ { bt = b; b = b.hermitian (); - if (permB.length () == 0) + if (permB.numel () == 0) { permB = ColumnVector (n); for (octave_idx_type i = 0; i < n; i++) @@ -3137,10 +3136,10 @@ return -1; } - if (have_b && cholB && permB.length () != 0) + if (have_b && cholB && permB.numel () != 0) { // Check that we really have a permutation vector - if (permB.length () != n) + if (permB.numel () != n) { (*current_liboctave_error_handler) ("eigs: permB vector invalid"); return -1; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/fCmplxCHOL.cc --- a/liboctave/numeric/fCmplxCHOL.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/fCmplxCHOL.cc Sat May 30 05:39:47 2015 -0400 @@ -200,7 +200,7 @@ { octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { FloatComplexColumnVector utmp = u; @@ -220,7 +220,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { FloatComplexColumnVector utmp = u; @@ -243,7 +243,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/fCmplxLU.cc --- a/liboctave/numeric/fCmplxLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/fCmplxLU.cc Sat May 30 05:39:47 2015 -0400 @@ -98,7 +98,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatComplexColumnVector utmp = u; FloatComplexColumnVector vtmp = v; @@ -150,7 +150,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatComplexColumnVector utmp = u; FloatComplexColumnVector vtmp = v; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/fCmplxQR.cc --- a/liboctave/numeric/fCmplxQR.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/fCmplxQR.cc Sat May 30 05:39:47 2015 -0400 @@ -216,7 +216,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatComplexColumnVector utmp = u; FloatComplexColumnVector vtmp = v; @@ -265,7 +265,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -299,14 +299,14 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -324,7 +324,7 @@ } OCTAVE_LOCAL_BUFFER (float, rw, kmax); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; F77_XFCN (cqrinc, CQRINC, (m, n + ii, std::min (kmax, k + ii), @@ -371,7 +371,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -383,7 +383,7 @@ else if (nj > 0) { OCTAVE_LOCAL_BUFFER (float, rw, k); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; F77_XFCN (cqrdec, CQRDEC, (m, n - ii, k == m ? k : k - ii, @@ -411,7 +411,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = std::min (m, n); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -484,7 +484,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { init (q*r + FloatComplexMatrix (u) * FloatComplexMatrix (v).hermitian (), get_type ()); @@ -582,7 +582,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -603,21 +603,21 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); else if (nj > 0) { FloatComplexMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::insert_col (a, js(i), u.column (i)); init (a, get_type ()); } @@ -647,7 +647,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -659,7 +659,7 @@ else if (nj > 0) { FloatComplexMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::delete_col (a, js(i)); init (a, get_type ()); } @@ -673,7 +673,7 @@ octave_idx_type m = r.rows (); octave_idx_type n = r.columns (); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/floatCHOL.cc --- a/liboctave/numeric/floatCHOL.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/floatCHOL.cc Sat May 30 05:39:47 2015 -0400 @@ -205,7 +205,7 @@ { octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { FloatColumnVector utmp = u; @@ -225,7 +225,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { FloatColumnVector utmp = u; @@ -247,7 +247,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); @@ -309,7 +309,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { init (chol_mat.transpose () * chol_mat + FloatMatrix (u) * FloatMatrix (u).transpose (), false); @@ -335,7 +335,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () == n) + if (u.numel () == n) { if (singular (chol_mat)) info = 2; @@ -361,7 +361,7 @@ octave_idx_type n = chol_mat.rows (); - if (u.length () != n + 1) + if (u.numel () != n + 1) (*current_liboctave_error_handler) ("cholinsert: dimension mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("cholinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/floatLU.cc --- a/liboctave/numeric/floatLU.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/floatLU.cc Sat May 30 05:39:47 2015 -0400 @@ -97,7 +97,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatColumnVector utmp = u; FloatColumnVector vtmp = v; @@ -149,7 +149,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = l.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatColumnVector utmp = u; FloatColumnVector vtmp = v; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/floatQR.cc --- a/liboctave/numeric/floatQR.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/floatQR.cc Sat May 30 05:39:47 2015 -0400 @@ -211,7 +211,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { FloatColumnVector utmp = u; FloatColumnVector vtmp = v; @@ -255,7 +255,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = q.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -288,14 +288,14 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -313,7 +313,7 @@ } OCTAVE_LOCAL_BUFFER (float, w, kmax); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; FloatColumnVector utmp = u.column (jsi(i)); @@ -361,7 +361,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -373,7 +373,7 @@ else if (nj > 0) { OCTAVE_LOCAL_BUFFER (float, w, k); - for (volatile octave_idx_type i = 0; i < js.length (); i++) + for (volatile octave_idx_type i = 0; i < js.numel (); i++) { octave_idx_type ii = i; F77_XFCN (sqrdec, SQRDEC, (m, n - ii, k == m ? k : k - ii, @@ -401,7 +401,7 @@ octave_idx_type n = r.columns (); octave_idx_type k = std::min (m, n); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -471,7 +471,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () == m && v.length () == n) + if (u.numel () == m && v.numel () == n) { init (q*r + FloatMatrix (u) * FloatMatrix (v).transpose (), get_type ()); } @@ -566,7 +566,7 @@ octave_idx_type m = q.rows (); octave_idx_type n = r.columns (); - if (u.length () != m) + if (u.numel () != m) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > n) (*current_liboctave_error_handler) ("qrinsert: index out of range"); @@ -586,21 +586,21 @@ Array jsi; Array js = j.sort (jsi, 0, ASCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); if (dups) (*current_liboctave_error_handler) ("qrinsert: duplicate index detected"); - else if (u.length () != m || u.columns () != nj) + else if (u.numel () != m || u.columns () != nj) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (nj > 0 && (js(0) < 0 || js(nj-1) > n)) (*current_liboctave_error_handler) ("qrinsert: index out of range"); else if (nj > 0) { FloatMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::insert_col (a, js(i), u.column (i)); init (a, get_type ()); } @@ -630,7 +630,7 @@ Array jsi; Array js = j.sort (jsi, 0, DESCENDING); - octave_idx_type nj = js.length (); + octave_idx_type nj = js.numel (); bool dups = false; for (octave_idx_type i = 0; i < nj - 1; i++) dups = dups && js(i) == js(i+1); @@ -642,7 +642,7 @@ else if (nj > 0) { FloatMatrix a = q*r; - for (octave_idx_type i = 0; i < js.length (); i++) + for (octave_idx_type i = 0; i < js.numel (); i++) a = ::delete_col (a, js(i)); init (a, get_type ()); } @@ -656,7 +656,7 @@ octave_idx_type m = r.rows (); octave_idx_type n = r.columns (); - if (! q.is_square () || u.length () != n) + if (! q.is_square () || u.numel () != n) (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); else if (j < 0 || j > m) (*current_liboctave_error_handler) ("qrinsert: index out of range"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/lo-specfun.cc --- a/liboctave/numeric/lo-specfun.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/lo-specfun.cc Sat May 30 05:39:47 2015 -0400 @@ -1,8 +1,10 @@ /* Copyright (C) 1996-2015 John W. Eaton +Copyright (C) 2007-2010 D. Martin Copyright (C) 2010 Jaroslav Hajek Copyright (C) 2010 VZLU Prague +Copyright (C) 2015 Carnë Draug This file is part of Octave. @@ -45,6 +47,7 @@ #include "lo-specfun.h" #include "mx-inlines.cc" #include "lo-mappers.h" +#include "lo-math.h" #include "Faddeeva.hh" @@ -183,6 +186,16 @@ F77_RET_T F77_FUNC (algams, ALGAMS) (const float&, float&, float&); + + F77_RET_T + F77_FUNC (psifn, PSIFN) (const float*, const octave_idx_type&, + const octave_idx_type&, const octave_idx_type&, + float*, octave_idx_type*, octave_idx_type*); + + F77_RET_T + F77_FUNC (dpsifn, DPSIFN) (const double*, const octave_idx_type&, + const octave_idx_type&, const octave_idx_type&, + double*, octave_idx_type*, octave_idx_type*); } #if !defined (HAVE_ACOSH) @@ -1264,8 +1277,8 @@ const ComplexColumnVector& x, bool scaled, Array& ierr) { - octave_idx_type nr = x.length (); - octave_idx_type nc = alpha.length (); + octave_idx_type nr = x.numel (); + octave_idx_type nc = alpha.numel (); ComplexMatrix retval (nr, nc); @@ -1875,8 +1888,8 @@ const FloatComplexColumnVector& x, bool scaled, Array& ierr) { - octave_idx_type nr = x.length (); - octave_idx_type nc = alpha.length (); + octave_idx_type nr = x.numel (); + octave_idx_type nc = alpha.numel (); FloatComplexMatrix retval (nr, nc); @@ -3237,14 +3250,14 @@ for ( ; ; ) { - term = term * temp * rx / (pp + ai); - value = value + term; + term *= temp * rx / (pp + ai); + value += term; temp = fabs (term); if (temp <= acu && temp <= acu * value) { - value = value * exp (pp * gnulib::log (xx) - + (qq - 1.0) * gnulib::log (cx) - beta) / pp; + value *= exp (pp * gnulib::log (xx) + + (qq - 1.0) * gnulib::log (cx) - beta) / pp; if (indx) { @@ -3253,8 +3266,8 @@ break; } - ai = ai + 1.0; - ns = ns - 1; + ai += 1.0; + ns -= 1; if (0 <= ns) { @@ -3267,7 +3280,7 @@ else { temp = psq; - psq = psq + 1.0; + psq += 1.0; } } @@ -3439,7 +3452,7 @@ break; } } - g = g / 3.0; + g /= 3.0; } if (prev <= acu) @@ -3465,7 +3478,7 @@ break; } - g = g / 3.0; + g /= 3.0; } if (tx == value) @@ -3724,3 +3737,185 @@ dn = Complex (dd*cc1*dd1/ddd, -m*ss*cc*ss1/ddd); } } + +static const double pi = 3.14159265358979323846; + +template +static T +Lanczos_approximation_psi (const T zc) +{ + // Coefficients for C.Lanczos expansion of psi function from XLiFE++ gammaFunctions + // psi_coef[k] = - (2k+1) * lg_coef[k] (see melina++ gamma functions) + // -1/12, 3/360,-5/1260, 7/1680,-9/1188, 11*691/360360,-13/156, 15*3617/122400, ? , ? + static const T dg_coeff[10] = { + -0.83333333333333333e-1, 0.83333333333333333e-2, + -0.39682539682539683e-2, 0.41666666666666667e-2, + -0.75757575757575758e-2, 0.21092796092796093e-1, + -0.83333333333333333e-1, 0.4432598039215686, + -0.3053954330270122e+1, 0.125318899521531e+2 + }; + + T overz2 = T (1.0) / (zc * zc); + T overz2k = overz2; + + T p = 0; + for (octave_idx_type k = 0; k < 10; k++, overz2k *= overz2) + p += dg_coeff[k] * overz2k; + p += log (zc) - T (0.5) / zc; + return p; +} + +template +T +psi (const T& z) +{ + static const double euler_mascheroni = 0.577215664901532860606512090082402431042; + + const bool is_int = (xfloor (z) == z); + + T p = 0; + if (z <= 0) + { + // limits - zeros of the gamma function + if (is_int) + p = -octave_Inf; // Matlab returns -Inf for psi (0) + else + // Abramowitz and Stegun, page 259, eq 6.3.7 + p = psi (1 - z) - (pi / tan (pi * z)); + } + else if (is_int) + { + // Abramowitz and Stegun, page 258, eq 6.3.2 + p = - euler_mascheroni; + for (octave_idx_type k = z - 1; k > 0; k--) + p += 1.0 / k; + } + else if (xfloor (z + 0.5) == z + 0.5) + { + // Abramowitz and Stegun, page 258, eq 6.3.3 and 6.3.4 + for (octave_idx_type k = z; k > 0; k--) + p += 1.0 / (2 * k - 1); + + p = - euler_mascheroni - 2 * log (2) + 2 * (p); + } + else + { + // adapted from XLiFE++ gammaFunctions + + T zc = z; + // Use formula for derivative of LogGamma(z) + if (z < 10) + { + const signed char n = 10 - z; + for (signed char k = n - 1; k >= 0; k--) + p -= 1.0 / (k + z); + zc += n; + } + p += Lanczos_approximation_psi (zc); + } + + return p; +} + +// explicit instantiations +template double psi (const double& z); +template float psi (const float& z); + +template +std::complex +psi (const std::complex& z) +{ + // adapted from XLiFE++ gammaFunctions + + typedef typename std::complex::value_type P; + + P z_r = z.real (); + P z_ra = z_r; + + std::complex dgam (0.0, 0.0); + if (z.imag () == 0) + dgam = std::complex (psi (z_r), 0.0); + else if (z_r < 0) + dgam = psi (P (1.0) - z)- (P (pi) / tan (P (pi) * z)); + else + { + // Use formula for derivative of LogGamma(z) + std::complex z_m = z; + if (z_ra < 8) + { + unsigned char n = 8 - z_ra; + z_m = z + std::complex (n, 0.0); + + // Recurrence formula + // for | Re(z) | < 8 , use recursively DiGamma(z) = DiGamma(z+1) - 1/z + std::complex z_p = z + P (n - 1); + for (unsigned char k = n; k > 0; k--, z_p -= 1.0) + dgam -= P (1.0) / z_p; + } + + // for | Re(z) | > 8, use derivative of C.Lanczos expansion for LogGamma + // psi(z) = log(z) - 1/(2z) - 1/12z^2 + 3/360z^4 - 5/1260z^6 + 7/1680z^8 - 9/1188z^10 + ... + // (Abramowitz&Stegun, page 259, formula 6.3.18 + dgam += Lanczos_approximation_psi (z_m); + } + return dgam; +} + +// explicit instantiations +template Complex psi (const Complex& z); +template FloatComplex psi (const FloatComplex& z); + + +template +static inline void +fortran_psifn (const T z, const octave_idx_type n, T* ans, + octave_idx_type* ierr); + +template<> +inline void +fortran_psifn (const double z, const octave_idx_type n, + double* ans, octave_idx_type* ierr) +{ + octave_idx_type flag = 0; + F77_XFCN (dpsifn, DPSIFN, (&z, n, 1, 1, ans, &flag, ierr)); +} + +template<> +inline void +fortran_psifn (const float z, const octave_idx_type n, + float* ans, octave_idx_type* ierr) +{ + octave_idx_type flag = 0; + F77_XFCN (psifn, PSIFN, (&z, n, 1, 1, ans, &flag, ierr)); +} + +template +T +psi (const octave_idx_type n, const T z) +{ + T ans; + octave_idx_type ierr = 0; + fortran_psifn (z, n, &ans, &ierr); + if (ierr == 0) + { + // Remember that psifn and dpsifn return scales values + // When n is 1: do nothing since ((-1)**(n+1)/gamma(n+1)) == 1 + // When n is 0: change sign since ((-1)**(n+1)/gamma(n+1)) == -1 + if (n > 1) + // FIXME xgamma here is a killer for our precision since it grows + // way too fast + ans = ans / (pow (-1.0, n + 1) / xgamma (double (n+1))); + else if (n == 0) + ans = -ans; + } + else if (ierr == 2) + ans = - octave_Inf; + else // we probably never get here + ans = octave_NaN; + + return ans; +} + +// explicit instantiations +template double psi (const octave_idx_type n, const double z); +template float psi (const octave_idx_type n, const float z); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/lo-specfun.h --- a/liboctave/numeric/lo-specfun.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/lo-specfun.h Sat May 30 05:39:47 2015 -0400 @@ -663,4 +663,24 @@ ellipj (const Complex& u, double m, Complex& sn, Complex& cn, Complex& dn, double& err); +//! Digamma function. +//! +//! Only defined for double and float. +template +extern OCTAVE_API T psi (const T& z); + +//! Digamma function for complex input. +//! +//! Only defined for double and float. +template +extern OCTAVE_API std::complex psi (const std::complex& z); + +//! Polygamma function. +//! +//! Only defined for double and float. +//! @param n must be non-negative. If zero, the digamma function is computed. +//! @param z must be real and non-negative. +template +extern OCTAVE_API T psi (const octave_idx_type n, const T z); + #endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/oct-rand.cc --- a/liboctave/numeric/oct-rand.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/oct-rand.cc Sat May 30 05:39:47 2015 -0400 @@ -513,7 +513,7 @@ { retval.clear (n, 1); - fill (retval.capacity (), retval.fortran_vec (), a); + fill (retval.numel (), retval.fortran_vec (), a); } else if (n < 0) (*current_liboctave_error_handler) ("rand: invalid negative argument"); @@ -530,7 +530,7 @@ { retval.clear (n, 1); - fill (retval.capacity (), retval.fortran_vec (), a); + fill (retval.numel (), retval.fortran_vec (), a); } else if (n < 0) (*current_liboctave_error_handler) ("rand: invalid negative argument"); @@ -547,7 +547,7 @@ { retval.clear (dims); - fill (retval.capacity (), retval.fortran_vec (), a); + fill (retval.numel (), retval.fortran_vec (), a); } return retval; @@ -562,7 +562,7 @@ { retval.clear (dims); - fill (retval.capacity (), retval.fortran_vec (), a); + fill (retval.numel (), retval.fortran_vec (), a); } return retval; @@ -690,7 +690,7 @@ void octave_rand::set_internal_state (const ColumnVector& s) { - octave_idx_type len = s.length (); + octave_idx_type len = s.numel (); octave_idx_type n = len < MT_N + 1 ? len : MT_N + 1; OCTAVE_LOCAL_BUFFER (uint32_t, tmp, MT_N + 1); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/oct-spparms.cc --- a/liboctave/numeric/oct-spparms.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/oct-spparms.cc Sat May 30 05:39:47 2015 -0400 @@ -177,7 +177,7 @@ bool octave_sparse_params::do_set_vals (const NDArray& vals) { - octave_idx_type len = vals.length (); + octave_idx_type len = vals.numel (); if (len > OCTAVE_SPARSE_CONTROLS_SIZE) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/numeric/sparse-base-chol.cc --- a/liboctave/numeric/sparse-base-chol.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/numeric/sparse-base-chol.cc Sat May 30 05:39:47 2015 -0400 @@ -280,7 +280,7 @@ MatrixType mattype (MatrixType::Upper); chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0); - if (perms.length () == n) + if (perms.numel () == n) { p_type Qc = Q (); retval = Qc * linv * linv.hermitian () * Qc.transpose (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/operators/mx-inlines.cc --- a/liboctave/operators/mx-inlines.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/operators/mx-inlines.cc Sat May 30 05:39:47 2015 -0400 @@ -371,7 +371,7 @@ if (dx == dy) { Array r (dx); - op (r.length (), r.fortran_vec (), x.data (), y.data ()); + op (r.numel (), r.fortran_vec (), x.data (), y.data ()); return r; } else if (is_valid_bsxfun (opname, dx, dy)) @@ -391,7 +391,7 @@ void (*op) (size_t, R *, const X *, Y) throw ()) { Array r (x.dims ()); - op (r.length (), r.fortran_vec (), x.data (), y); + op (r.numel (), r.fortran_vec (), x.data (), y); return r; } @@ -401,7 +401,7 @@ void (*op) (size_t, R *, X, const Y *) throw ()) { Array r (y.dims ()); - op (r.length (), r.fortran_vec (), x, y.data ()); + op (r.numel (), r.fortran_vec (), x, y.data ()); return r; } @@ -416,7 +416,7 @@ dim_vector dx = x.dims (); if (dr == dx) { - op (r.length (), r.fortran_vec (), x.data ()); + op (r.numel (), r.fortran_vec (), x.data ()); } else if (is_valid_inplace_bsxfun (opname, dr, dx)) { @@ -432,7 +432,7 @@ do_ms_inplace_op (Array& r, const X& x, void (*op) (size_t, R *, X) throw ()) { - op (r.length (), r.fortran_vec (), x); + op (r.numel (), r.fortran_vec (), x); return r; } @@ -1179,9 +1179,9 @@ // calculate extent triplet. l = 1, n = dims(dim), u = 1; for (octave_idx_type i = 0; i < dim; i++) - l *= dims (i); + l *= dims(i); for (octave_idx_type i = dim + 1; i < ndims; i++) - u *= dims (i); + u *= dims(i); } } @@ -1199,7 +1199,7 @@ dim_vector dims = src.dims (); // M*b inconsistency: sum ([]) = 0 etc. if (dims.length () == 2 && dims(0) == 0 && dims(1) == 0) - dims (1) = 1; + dims(1) = 1; get_extent_triplet (dims, dim, l, n, u); @@ -1327,7 +1327,7 @@ if (dims(dim) <= order) { - dims (dim) = 0; + dims(dim) = 0; return Array (dims); } else diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/system/file-ops.cc --- a/liboctave/system/file-ops.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/system/file-ops.cc Sat May 30 05:39:47 2015 -0400 @@ -152,7 +152,7 @@ { for (size_t i = 0; i < s_len; i++) { - for (int j = 0; j < prefixes.length (); j++) + for (int j = 0; j < prefixes.numel (); j++) { size_t pfx_len = prefixes[j].length (); @@ -187,7 +187,7 @@ if (! suffixes.empty ()) { - for (int j = 0; j < suffixes.length (); j++) + for (int j = 0; j < suffixes.numel (); j++) { size_t sfx_len = suffixes[j].length (); @@ -346,7 +346,7 @@ { string_vector retval; - int n = names.length (); + int n = names.numel (); retval.resize (n); @@ -580,7 +580,7 @@ { string_vector dirlist = dir.read (); - for (octave_idx_type i = 0; i < dirlist.length (); i++) + for (octave_idx_type i = 0; i < dirlist.numel (); i++) { octave_quit (); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/glob-match.h --- a/liboctave/util/glob-match.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/glob-match.h Sat May 30 05:39:47 2015 -0400 @@ -72,7 +72,7 @@ Array match (const string_vector& str) const { - int n = str.length (); + int n = str.numel (); Array retval (dim_vector (n, 1)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/kpse.cc --- a/liboctave/util/kpse.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/kpse.cc Sat May 30 05:39:47 2015 -0400 @@ -427,7 +427,7 @@ gnulib::fputs (" (nil)\n", stderr); else { - int len = ret.length (); + int len = ret.numel (); for (int i = 0; i < len; i++) { gnulib::putc (' ', stderr); @@ -704,7 +704,7 @@ if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH) || log_file) { /* FILENAMES should never be null, but safety doesn't hurt. */ - for (int e = 0; e < filenames.length () && ! filenames[e].empty (); e++) + for (int e = 0; e < filenames.numel () && ! filenames[e].empty (); e++) { std::string filename = filenames[e]; @@ -1010,7 +1010,7 @@ { const std::string dir = STR_LLIST (*dirs_elt); - int len = names.length (); + int len = names.numel (); for (int i = 0; i < len && !done; i++) { std::string name = names[i]; @@ -1076,7 +1076,7 @@ { gnulib::fputs ("start find_first_of ((", stderr); - int len = names.length (); + int len = names.numel (); for (int i = 0; i < len; i++) { @@ -1090,7 +1090,7 @@ path.c_str (), must_exist); } - for (int i = 0; i < names.length (); i++) + for (int i = 0; i < names.numel (); i++) { std::string name = names[i]; @@ -1125,7 +1125,7 @@ { gnulib::fputs ("find_first_of (", stderr); - int len = names.length (); + int len = names.numel (); for (int i = 0; i < len; i++) { @@ -1337,7 +1337,7 @@ string_vector expansions = brace_expand (elt); - for (int i = 0; i < expansions.length (); i++) + for (int i = 0; i < expansions.numel (); i++) { /* Do $ and ~ expansion on each element. */ std::string x = kpse_expand (expansions[i]); @@ -1511,8 +1511,8 @@ result = arr1; else { - int len1 = arr1.length (); - int len2 = arr2.length (); + int len1 = arr1.numel (); + int len2 = arr2.numel (); result = string_vector (len1 * len2); @@ -1886,7 +1886,7 @@ extra couple of hash lookups matter -- they don't -- but rather because we want to return NULL in this case, so path_search can know to do a disk search. */ - for (int e = 0; ! relevant && e < db_dir_list.length (); e++) + for (int e = 0; ! relevant && e < db_dir_list.numel (); e++) relevant = elt_in_db (db_dir_list[e], path_elt); if (! relevant) @@ -1897,14 +1897,14 @@ aliases = hash_lookup (alias_db, name); /* Push aliases up by one and insert the original name at the front. */ - int len = aliases.length (); + int len = aliases.numel (); aliases.resize (len+1); for (int i = len; i > 0; i--) aliases[i] = aliases[i - 1]; aliases[0] = name; done = false; - len = aliases.length (); + len = aliases.numel (); for (int i = 0; i < len && !done; i++) { std::string atry = aliases[i]; @@ -1916,7 +1916,7 @@ example, if we have .../cx/cmr10.300pk and .../ricoh/cmr10.300pk, and the path looks like .../cx, we don't want the ricoh file. */ - int db_dirs_len = db_dirs.length (); + int db_dirs_len = db_dirs.numel (); for (int j = 0; j < db_dirs_len && !done; j++) { std::string db_file = db_dirs[j] + atry; @@ -1946,7 +1946,7 @@ and shouldn't hurt. The upshot is that if one of the aliases actually exists, we use that. */ - int aliases_len = aliases.length (); + int aliases_len = aliases.numel (); for (int k = 1; k < aliases_len && found.empty (); k++) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/lo-regexp.cc --- a/liboctave/util/lo-regexp.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/lo-regexp.cc Sat May 30 05:39:47 2015 -0400 @@ -434,11 +434,11 @@ Array regexp::is_match (const string_vector& buffer) { - octave_idx_type len = buffer.length (); + octave_idx_type len = buffer.numel (); Array retval (dim_vector (len, 1)); - for (octave_idx_type i = 0; i < buffer.length (); i++) + for (octave_idx_type i = 0; i < buffer.numel (); i++) retval(i) = is_match (buffer(i)); return retval; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/oct-glob.cc --- a/liboctave/util/oct-glob.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/oct-glob.cc Sat May 30 05:39:47 2015 -0400 @@ -51,7 +51,7 @@ octave_fnmatch (const string_vector& pat, const std::string& str, int fnmatch_flags) { - int npat = pat.length (); + int npat = pat.numel (); const char *cstr = str.c_str (); @@ -67,7 +67,7 @@ { string_vector retval; - int npat = pat.length (); + int npat = pat.numel (); int k = 0; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/pathsearch.cc --- a/liboctave/util/pathsearch.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/pathsearch.cc Sat May 30 05:39:47 2015 -0400 @@ -79,7 +79,7 @@ if (initialized) { - int len = pv.length (); + int len = pv.numel (); int nmax = len > 32 ? len : 32; diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/str-vec.cc --- a/liboctave/util/str-vec.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/str-vec.cc Sat May 30 05:39:47 2015 -0400 @@ -108,7 +108,7 @@ { // Don't use Array::sort () to allow sorting in place. octave_sort lsort; - lsort.sort (Array::fortran_vec (), length ()); + lsort.sort (Array::fortran_vec (), numel ()); if (make_uniq) uniq (); @@ -118,7 +118,7 @@ string_vector& string_vector::uniq (void) { - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -139,7 +139,7 @@ string_vector& string_vector::append (const std::string& s) { - octave_idx_type len = length (); + octave_idx_type len = numel (); resize (len + 1); @@ -151,8 +151,8 @@ string_vector& string_vector::append (const string_vector& sv) { - octave_idx_type len = length (); - octave_idx_type sv_len = sv.length (); + octave_idx_type len = numel (); + octave_idx_type sv_len = sv.numel (); octave_idx_type new_len = len + sv_len; resize (new_len); @@ -168,7 +168,7 @@ { std::string retval; - octave_idx_type len = length (); + octave_idx_type len = numel (); if (len > 0) { @@ -186,7 +186,7 @@ char ** string_vector::c_str_vec (void) const { - octave_idx_type len = length (); + octave_idx_type len = numel (); char **retval = new char * [len + 1]; @@ -218,7 +218,7 @@ // Compute the maximum name length. octave_idx_type max_name_length = 0; - octave_idx_type total_names = length (); + octave_idx_type total_names = numel (); if (total_names == 0) { diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/str-vec.h --- a/liboctave/util/str-vec.h Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/str-vec.h Sat May 30 05:39:47 2015 -0400 @@ -70,11 +70,11 @@ ~string_vector (void) { } - bool empty (void) const { return length () == 0; } + bool empty (void) const { return numel () == 0; } octave_idx_type max_length (void) const { - octave_idx_type n = length (); + octave_idx_type n = numel (); octave_idx_type longest = 0; for (octave_idx_type i = 0; i < n; i++) diff -r 3ccc2d02e64b -r 3e8c188b20a7 liboctave/util/url-transfer.cc --- a/liboctave/util/url-transfer.cc Sat May 23 10:35:40 2015 -0400 +++ b/liboctave/util/url-transfer.cc Sat May 30 05:39:47 2015 -0400 @@ -82,7 +82,7 @@ string_vector sv = list (); - for (octave_idx_type i = 0; i < sv.length (); i++) + for (octave_idx_type i = 0; i < sv.numel (); i++) { time_t ftime; bool fisdir; @@ -153,7 +153,7 @@ { string_vector files = dirlist.read (); - for (octave_idx_type i = 0; i < files.length (); i++) + for (octave_idx_type i = 0; i < files.numel (); i++) { std::string file = files (i); diff -r 3ccc2d02e64b -r 3e8c188b20a7 m4/acinclude.m4 --- a/m4/acinclude.m4 Sat May 23 10:35:40 2015 -0400 +++ b/m4/acinclude.m4 Sat May 30 05:39:47 2015 -0400 @@ -291,7 +291,7 @@ [AC_LANG_PUSH(C++) ac_octave_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ #if QSCINTILLA_VERSION < 0x020600 @@ -417,7 +417,7 @@ [AC_LANG_PUSH(C++) ac_octave_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ #if QT_VERSION < 0x040700 diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/audio/@audioplayer/set.m --- a/scripts/audio/@audioplayer/set.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/audio/@audioplayer/set.m Sat May 30 05:39:47 2015 -0400 @@ -50,7 +50,7 @@ index = 1; for property = varargin{2} setproperty (player, char (property), varargin{3}{index}); - index = index + 1; + index += 1; endfor else setproperty (player, varargin{2}, varargin{3}); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/audio/@audiorecorder/set.m --- a/scripts/audio/@audiorecorder/set.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/audio/@audiorecorder/set.m Sat May 30 05:39:47 2015 -0400 @@ -50,7 +50,7 @@ index = 1; for property = varargin{2} setproperty (recorder, char (property), varargin{3}{index}); - index = index + 1; + index += 1; endfor else setproperty (recorder, varargin{2}, varargin{3}); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/audio/mu2lin.m --- a/scripts/audio/mu2lin.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/audio/mu2lin.m Sat May 30 05:39:47 2015 -0400 @@ -69,7 +69,7 @@ ## Convert to real or 8-bit. if (n == 0) ## [ -32768, 32767 ] -> [ -1, 1) - y = y/32768; + y /= 32768; elseif (n == 8) ld = max (abs (y (:))); if (ld < 16384 && ld > 0) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/default_save_options.m --- a/scripts/deprecated/default_save_options.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -## Copyright (C) 2013-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{val} =} default_save_options () -## @deftypefnx {Built-in Function} {@var{old_val} =} default_save_options (@var{new_val}) -## @deftypefnx {Built-in Function} {} default_save_options (@var{new_val}, "local") -## This function has been deprecated. Use @code{@file{save_default_options}} -## instead. -## @seealso{save_default_options} -## @end deftypefn - -## Deprecated in 3.8 - -function retval = default_save_options (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "default_save_options is obsolete and will be removed from a future version of Octave, please use save_default_options instead"); - endif - - retval = save_default_options (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/gen_doc_cache.m --- a/scripts/deprecated/gen_doc_cache.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -## Copyright (C) 2013-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} gen_doc_cache (@var{out_file}, @var{directory}) -## This function has been deprecated. Use @code{doc_cache_create} instead. -## @seealso{doc_cache_create} -## @end deftypefn - -## Deprecated in 3.8 - -function gen_doc_cache (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "gen_doc_cache is obsolete and will be removed from a future version of Octave, please use doc_cache_create instead"); - endif - - doc_cache_create (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/interp1q.m --- a/scripts/deprecated/interp1q.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -## Copyright (C) 2008-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{yi} =} interp1q (@var{x}, @var{y}, @var{xi}) -## One-dimensional linear interpolation without error checking. -## Interpolates @var{y}, defined at the points @var{x}, at the points -## @var{xi}. The sample points @var{x} must be a strictly monotonically -## increasing column vector. If @var{y} is a matrix or an N-dimensional -## array, the interpolation is performed on each column of @var{y}. If -## @var{y} is a vector, it must be a column vector of the same length as -## @var{x}. -## -## Values of @var{xi} beyond the endpoints of the interpolation result -## in NA being returned. -## -## Note that the error checking is only a significant portion of the -## execution time of this @code{interp1} if the size of the input arguments -## is relatively small. Therefore, the benefit of using @code{interp1q} -## is relatively small. -## @seealso{interp1} -## @end deftypefn - -function yi = interp1q (x, y, xi) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "interp1q is obsolete and will be removed from a future version of Octave; use interp1 instead"); - endif - - x = x(:); - nx = rows (x); - szy = size (y); - y = y(:,:); - [ny, nc] = size (y); - szx = size (xi); - xi = xi (:); - dy = diff (y); - dx = diff (x); - idx = lookup (x, xi, "lr"); - s = (xi - x(idx)) ./ dx(idx); - yi = bsxfun (@times, s, dy(idx,:)) + y(idx,:); - range = xi < x(1) | !(xi <= x(nx)); - yi(range,:) = NA; - if (length (szx) == 2 && any (szx == 1)) - yi = reshape (yi, [max(szx), szy(2:end)]); - else - yi = reshape (yi, [szx, szy(2:end)]); - endif -endfunction - - -%!shared xp, yp, xi, yi -%! xp = [0:2:10].'; yp = sin (2*pi*xp/5); -%! xi = [-1; 0; 2.2; 4; 6.6; 10; 11]; -%! yi = interp1 (xp,yp,xi); -%!assert (interp1q (xp,yp, [min(xp)-1; max(xp)+1]), [NA; NA]); -%!assert (interp1q (xp,yp,xp), yp, 100*eps); -%!assert (isempty (interp1q (xp,yp,[]))); -%!assert (interp1q (xp,yp,xi), yi); -%!assert (interp1q (xp,[yp,yp],xi), [yi, yi]); -%!assert (interp1q (xp,yp,[xi,xi]), [yi, yi]); -%!assert (interp1q (xp,[yp,yp],[xi,xi]), cat (3, [yi, yi], [yi, yi])); - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/isequalwithequalnans.m --- a/scripts/deprecated/isequalwithequalnans.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -## Copyright (C) 2005-2015 William Poetra Yoga Hadisoeseno -## -## 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 -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} isequalwithequalnans (@var{x1}, @var{x2}, @dots{}) -## This function has been deprecated. Use @code{@file{isequaln}} instead. -## @seealso{isequaln} -## @end deftypefn - -## Deprecated in 3.8 - -function retval = isequalwithequalnans (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "isequalwithequalnans is obsolete and will be removed from a future version of Octave, please use isequaln instead"); - endif - - retval = isequaln (varargin{:}); - -endfunction - - -## test for equality -%!assert (isequalwithequalnans ({1,2,NaN,4},{1,2,NaN,4}), true) -%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,NaN,4]), true) -## test for inequality -%!assert (isequalwithequalnans ([1,2,NaN,4],[1,NaN,3,4]), false) -%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,3,4]), false) -## test for equality (struct) -%!assert (isequalwithequalnans (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true) -%!assert (isequalwithequalnans (1,2,1), false) - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/java_convert_matrix.m --- a/scripts/deprecated/java_convert_matrix.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -## Copyright (C) 2012-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{val} =} java_convert_matrix () -## @deftypefnx {Built-in Function} {@var{old_val} =} java_convert_matrix (@var{new_val}) -## @deftypefnx {Built-in Function} {} java_convert_matrix (@var{new_val}, "local") -## Query or set the internal variable that controls whether Java arrays are -## automatically converted to Octave matrices. The default value is false. -## -## 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. -## @seealso{java_matrix_autoconversion, java_unsigned_conversion, java_debug} -## @end deftypefn - -function old_val = java_convert_matrix (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "java_convert_matrix is obsolete and will be removed from a future version of Octave; use java_matrix_autoconversion instead"); - endif - - if (nargin > 2) - print_usage (); - endif - - old_val = java_matrix_autoconversion (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/java_debug.m --- a/scripts/deprecated/java_debug.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -## Copyright (C) 2012-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{val} =} java_debug () -## @deftypefnx {Built-in Function} {@var{old_val} =} java_debug (@var{new_val}) -## @deftypefnx {Built-in Function} {} java_debug (@var{new_val}, "local") -## Query or set the internal variable that determines whether extra debugging -## information regarding the initialization of the JVM and any Java exceptions -## is printed. -## -## 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. -## @seealso{debug_java, java_convert_matrix, java_unsigned_conversion} -## @end deftypefn - -function old_val = java_debug (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "java_debug is obsolete and will be removed from a future version of Octave; use debug_java instead"); - endif - - if (nargin > 2) - print_usage (); - endif - - old_val = debug_java (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/java_invoke.m --- a/scripts/deprecated/java_invoke.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -## Copyright (C) 2007, 2013 Michael Goffioul -## -## 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}) -## @deftypefnx {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}, @var{arg1}, @dots{}) -## Invoke the method @var{methodname} on the Java object @var{obj} with the -## arguments @var{arg1}, @dots{} For static methods, @var{obj} can be a -## string representing the fully qualified name of the corresponding class. -## The function returns the result of the method invocation. -## -## When @var{obj} is a regular Java object, structure-like indexing can be -## used as a shortcut syntax. For instance, the two following statements are -## equivalent -## -## @example -## @group -## ret = java_invoke (x, "method1", 1.0, "a string") -## ret = x.method1 (1.0, "a string") -## @end group -## @end example -## -## @seealso{javaMethod, javaObject} -## @end deftypefn - -function retval = java_invoke (obj, methodname, varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "java_invoke is obsolete and will be removed from a future version of Octave, please use javaMethod instead"); - endif - - if (nargin < 2) - print_usage (); - endif - - retval = javaMethod (methodname, obj, varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/java_new.m --- a/scripts/deprecated/java_new.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -## Copyright (C) 2012-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Loadable Function} {@var{obj} =} java_new (@var{name}) -## @deftypefnx {Loadable Function} {@var{obj} =} java_new (@var{name}, @var{arg1}, @dots{}) -## Create a Java object of class @var{name}, by calling the class constructor -## with the arguments @var{arg1}, @dots{} -## -## @example -## @group -## x = java_new ("java.lang.StringBuffer") -## x = java_new ("java.lang.StringBuffer", "Initial string") -## @end group -## @end example -## -## @seealso{javaObject, javaMethod} -## @end deftypefn - -function retval = java_new (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "java_new is obsolete and will be removed from a future version of Octave; please use javaObject instead"); - endif - - if (nargin < 1) - print_usage (); - endif - - retval = javaObject (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/java_unsigned_conversion.m --- a/scripts/deprecated/java_unsigned_conversion.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -## Copyright (C) 2012-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{val} =} java_unsigned_conversion () -## @deftypefnx {Built-in Function} {@var{old_val} =} java_unsigned_conversion (@var{new_val}) -## @deftypefnx {Built-in Function} {} java_unsigned_conversion (@var{new_val}, "local") -## Query or set the internal variable that controls how integer classes are -## converted when Java matrix autoconversion is enabled. When enabled, Java -## arrays of class Byte or Integer are converted to matrices of class uint8 or -## uint32 respectively. -## -## 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. -## @seealso{java_unsigned_autoconversion, java_convert_matrix, debug_java} -## @end deftypefn - -function old_val = java_unsigned_conversion (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "java_unsigned_conversion is obsolete and will be removed from a future version of Octave; use java_unsigned_autoconversion instead"); - endif - - if (nargin > 2) - print_usage (); - endif - - old_val = java_unsigned_autoconversion (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/javafields.m --- a/scripts/deprecated/javafields.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -## Copyright (C) 2007, 2013 Michael Goffioul -## -## 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 -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} javafields (@var{javaobj}) -## @deftypefnx {Function File} {} javafields ("@var{classname}") -## @deftypefnx {Function File} {@var{fld_names} =} javafields (@dots{}) -## Return the fields of a Java object or Java class in the form of a cell -## array of strings. If no output is requested, print the result -## to the standard output. -## @seealso{fieldnames, methods, javaObject} -## @end deftypefn - -function fld_names = javafields (javaobj) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "javafields is obsolete and will be removed from a future version of Octave, please use fieldnames instead"); - endif - - if (nargin != 1) - print_usage (); - endif - - c_methods = javaMethod ("getFields", "org.octave.ClassHelper", javaobj); - method_list = ostrsplit (c_methods, ';'); - - if (nargout == 0) - if (! isempty (method_list)) - disp (method_list); - endif - else - fld_names = cellstr (method_list); - endif - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/javamethods.m --- a/scripts/deprecated/javamethods.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -## Copyright (C) 2007, 2013 Michael Goffioul -## -## 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 -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} javamethods (@var{javaobj}) -## @deftypefnx {Function File} {} javamethods ("@var{classname}") -## @deftypefnx {Function File} {@var{mtd_names} =} javamethods (@dots{}) -## Return the methods of a Java object or Java class in the form of a cell -## array of strings. If no output is requested, print the result to the -## standard output. -## @seealso{methods, fieldnames, javaMethod, javaObject} -## @end deftypefn - -function mtd_names = javamethods (classname) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "javamethods is obsolete and will be removed from a future version of Octave, please use methods instead"); - endif - - if (nargin != 1) - print_usage (); - endif - - cls_methods = javaMethod ("getMethods", "org.octave.ClassHelper", classname); - method_list = ostrsplit (cls_methods, ';'); - - if (nargout == 0) - if (! isempty (method_list)) - disp (method_list); - endif - else - mtd_names = cellstr (method_list); - endif - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/module.mk --- a/scripts/deprecated/module.mk Sat May 23 10:35:40 2015 -0400 +++ b/scripts/deprecated/module.mk Sat May 30 05:39:47 2015 -0400 @@ -2,35 +2,21 @@ deprecated_FCN_FILES = \ deprecated/bicubic.m \ - deprecated/default_save_options.m \ deprecated/delaunay3.m \ deprecated/dump_prefs.m \ deprecated/find_dir_in_path.m \ deprecated/finite.m \ deprecated/fmod.m \ deprecated/fnmatch.m \ - deprecated/gen_doc_cache.m \ deprecated/gmap40.m \ - deprecated/interp1q.m \ - deprecated/isequalwithequalnans.m \ deprecated/isstr.m \ - deprecated/java_convert_matrix.m \ - deprecated/java_debug.m \ - deprecated/java_invoke.m \ - deprecated/java_new.m \ - deprecated/java_unsigned_conversion.m \ - deprecated/javafields.m \ - deprecated/javamethods.m \ deprecated/loadaudio.m \ deprecated/luinc.m \ deprecated/mouse_wheel_zoom.m \ deprecated/nfields.m \ deprecated/octave_tmp_file_name.m \ deprecated/playaudio.m \ - deprecated/re_read_readline_init_file.m \ - deprecated/read_readline_init_file.m \ deprecated/saveaudio.m \ - deprecated/saving_history.m \ deprecated/setaudio.m \ deprecated/syl.m \ deprecated/usage.m diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/re_read_readline_init_file.m --- a/scripts/deprecated/re_read_readline_init_file.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -## Copyright (C) 2013-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {} re_read_readline_init_file (@var{file}) -## This function has been deprecated. Use -## @code{@file{readline_re_read_init_file}} instead. -## @seealso{readline_read_init_file} -## @end deftypefn - -## Deprecated in 3.8 - -function re_read_readline_init_file (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "re_read_readline_init_file is obsolete and will be removed from a future version of Octave, please use readline_re_read_init_file instead"); - endif - - readline_re_read_init_file (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/read_readline_init_file.m --- a/scripts/deprecated/read_readline_init_file.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -## Copyright (C) 2013-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {} read_readline_init_file (@var{file}) -## This function has been deprecated. Use -## @code{@file{readline_read_init_file}} instead. -## @seealso{readline_read_init_file} -## @end deftypefn - -## Deprecated in 3.8 - -function read_readline_init_file (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "read_readline_init_file is obsolete and will be removed from a future version of Octave, please use readline_read_init_file instead"); - endif - - readline_read_init_file (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/deprecated/saving_history.m --- a/scripts/deprecated/saving_history.m Sat May 23 10:35:40 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -## Copyright (C) 2013-2015 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 -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {@var{val} =} saving_history () -## @deftypefnx {Built-in Function} {@var{old_val} =} saving_history (@var{new_val}) -## @deftypefnx {Built-in Function} {} saving_history (@var{new_val}, "local") -## This function has been deprecated. Use @code{@file{history_save}} instead. -## @seealso{history_save} -## @end deftypefn - -## Deprecated in 3.8 - -function retval = saving_history (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "saving_history is obsolete and will be removed from a future version of Octave, please use history_save instead"); - endif - - retval = save_default_options (varargin{:}); - -endfunction - diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/elfun/cosd.m --- a/scripts/elfun/cosd.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/elfun/cosd.m Sat May 30 05:39:47 2015 -0400 @@ -34,7 +34,7 @@ I = x / 180; y = cos (I .* pi); - I = I + 0.5; + I += 0.5; y(I == fix (I) & isfinite (I)) = 0; endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/del2.m --- a/scripts/general/del2.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/del2.m Sat May 30 05:39:47 2015 -0400 @@ -156,7 +156,7 @@ endif endfor - D = D ./ nd; + D ./= nd; endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/num2str.m --- a/scripts/general/num2str.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/num2str.m Sat May 30 05:39:47 2015 -0400 @@ -115,7 +115,8 @@ fmt = "%3d"; endif endif - fmt = [deblank(repmat(fmt, 1, columns(x))), "\n"]; + fmt = do_string_escapes (fmt); # required now that '\n' is interpreted. + fmt = [deblank(repmat (fmt, 1, columns (x))), "\n"]; nd = ndims (x); tmp = sprintf (fmt, permute (x, [2, 1, 3:nd])); retval = strtrim (char (ostrsplit (tmp(1:end-1), "\n"))); @@ -204,6 +205,9 @@ %!xtest %! assert (num2str (1e23), "100000000000000000000000"); +## Test for bug #44864, extra rows generated from newlines in format +%!assert (rows (num2str (magic (3), '%3d %3d %3d\n')), 3) + %!error num2str () %!error num2str (1, 2, 3) %!error num2str ({1}) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/profexplore.m --- a/scripts/general/profexplore.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/profexplore.m Sat May 30 05:39:47 2015 -0400 @@ -105,7 +105,7 @@ if (rv == 0) return; elseif (rv > 1) - rv = rv - 1; + rv -= 1; return; else assert (rv == 1); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/quadl.m --- a/scripts/general/quadl.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/quadl.m Sat May 30 05:39:47 2015 -0400 @@ -133,7 +133,7 @@ R = 1; endif if (R > 0 && R < 1) - tol = tol/R; + tol /= R; endif is = s * abs (is) * tol/myeps; if (is == 0) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/rat.m --- a/scripts/general/rat.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/rat.m Sat May 30 05:39:47 2015 -0400 @@ -102,7 +102,7 @@ if (nargout == 2) ## Move the minus sign to the top. - n = n .* sign (d); + n .*= sign (d); d = abs (d); ## Return the same shape as you receive. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/general/rotdim.m --- a/scripts/general/rotdim.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/general/rotdim.m Sat May 30 05:39:47 2015 -0400 @@ -78,7 +78,7 @@ plane = []; dim = 0; while (dim < nd) - dim = dim + 1; + dim += 1; if (sz (dim) != 1) plane = [plane, dim]; if (length (plane) == 2) @@ -104,7 +104,7 @@ n = rem (n, 4); if (n < 0) - n = n + 4; + n += 4; endif if (n == 0) y = x; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/geometry/griddata.m --- a/scripts/geometry/griddata.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/geometry/griddata.m Sat May 30 05:39:47 2015 -0400 @@ -133,14 +133,12 @@ error ("griddata: unknown interpolation METHOD"); endif - if (nargout == 3) + if (nargout > 1) rx = xi; ry = yi; rz = zi; - elseif (nargout == 1) + else rx = zi; - elseif (nargout == 0) - mesh (xi, yi, zi); endif endfunction @@ -153,7 +151,8 @@ %! y = 2*rand (size (x)) - 1; %! z = sin (2*(x.^2 + y.^2)); %! [xx,yy] = meshgrid (linspace (-1,1,32)); -%! griddata (x,y,z,xx,yy); +%! zz = griddata (x,y,z,xx,yy); +%! mesh (xx, yy, zz); %! title ("nonuniform grid sampled at 100 points"); %!demo @@ -163,7 +162,8 @@ %! y = 2*rand (size (x)) - 1; %! z = sin (2*(x.^2 + y.^2)); %! [xx,yy] = meshgrid (linspace (-1,1,32)); -%! griddata (x,y,z,xx,yy); +%! zz = griddata (x,y,z,xx,yy); +%! mesh (xx, yy, zz); %! title ("nonuniform grid sampled at 1000 points"); %!demo @@ -173,7 +173,8 @@ %! y = 2*rand (size (x)) - 1; %! z = sin (2*(x.^2 + y.^2)); %! [xx,yy] = meshgrid (linspace (-1,1,32)); -%! griddata (x,y,z,xx,yy,"nearest"); +%! zz = griddata (x,y,z,xx,yy,"nearest"); +%! mesh (xx, yy, zz); %! title ("nonuniform grid sampled at 1000 points with nearest neighbor"); %!testif HAVE_QHULL diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/gui/private/__fltk_file_filter__.m --- a/scripts/gui/private/__fltk_file_filter__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/gui/private/__fltk_file_filter__.m Sat May 30 05:39:47 2015 -0400 @@ -37,7 +37,7 @@ curr_ext = ostrsplit (curr_ext, ";"); if (length (curr_ext) > 1) - curr_ext = regexprep (curr_ext, '\*\.', ','); + curr_ext = strrep (curr_ext, '*.', ','); curr_ext = strcat (curr_ext{:})(2 : end); curr_ext = strcat ("*.{", curr_ext, "}"); else @@ -48,8 +48,8 @@ if (c == 2) curr_desc = file_filter{idx, 2}; - curr_desc = regexprep (curr_desc, '\(', '<'); - curr_desc = regexprep (curr_desc, '\)', '>'); + curr_desc = strrep (curr_desc, '(', '<'); + curr_desc = strrep (curr_desc, ')', '>'); endif if (length (fltk_str) > 0) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/help/get_first_help_sentence.m --- a/scripts/help/get_first_help_sentence.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/help/get_first_help_sentence.m Sat May 30 05:39:47 2015 -0400 @@ -117,9 +117,9 @@ ## Remove the @end ... that corresponds to the @def we removed above def1 = def_idx(1); space_idx = find (help_text == " "); - space_idx = space_idx (find (space_idx > def1, 1)); + space_idx = space_idx(find (space_idx > def1, 1)); bracket_idx = find (help_text == "{" | help_text == "}"); - bracket_idx = bracket_idx (find (bracket_idx > def1, 1)); + bracket_idx = bracket_idx(find (bracket_idx > def1, 1)); if (isempty (space_idx) && isempty (bracket_idx)) error ("get_first_help_sentence: couldn't parse texinfo"); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/help/private/__strip_html_tags__.m --- a/scripts/help/private/__strip_html_tags__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/help/private/__strip_html_tags__.m Sat May 30 05:39:47 2015 -0400 @@ -77,6 +77,6 @@ endfor ## Actually remove the elements - text = text (keep); + text = text(keep); endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/help/type.m --- a/scripts/help/type.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/help/type.m Sat May 30 05:39:47 2015 -0400 @@ -97,6 +97,19 @@ txt = sprintf ("%s is a dynamically-linked function", name); elseif (e == 5) txt = sprintf ("%s is a built-in function", name); + elseif (e == 103) + contents = __get_cmdline_fcn_txt__ (name); + if (isempty (contents)) + txt = sprintf ("%s is a command-line function with no definition", + name); + else + if (quiet) + txt = contents; + else + txt = sprintf ("%s is the command-line function:\n\n%s", + name, contents); + endif + endif elseif (any (strcmp (__operators__ (), name))) txt = sprintf ("%s is an operator", name); elseif (any (strcmp (__keywords__ (), name))) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/image/cubehelix.m --- a/scripts/image/cubehelix.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/image/cubehelix.m Sat May 30 05:39:47 2015 -0400 @@ -62,7 +62,7 @@ fract = ((0:n-1) / (n-1))'; angle = 2 * pi * (start/3 + 1 + rots*fract); - fract = fract .^ gamma; + fract .^= gamma; amp = hue * fract .* (1-fract) /2; map = fract + amp .* ([cos(angle) sin(angle)] * coeff); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/image/imformats.m --- a/scripts/image/imformats.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/image/imformats.m Sat May 30 05:39:47 2015 -0400 @@ -79,7 +79,7 @@ persistent formats = default_formats (); if (nargin == 0 && nargout == 0) - error ("imformats: pretty print not yet implemented."); + pretty_print_formats (formats); elseif (nargin >= 1) if (isstruct (arg1)) arrayfun (@is_valid_format, arg1); @@ -281,6 +281,40 @@ end_try_catch endfunction +function pretty_print_formats (formats) + ## define header names (none should be shorter than 3 characters) + headers = {"Extension", "isa", "Info", "Read", "Write", "Alpha", "Description"}; + cols_length = cellfun (@numel, headers); + + ## Adjust the maximal length of the extensions column + extensions = cellfun (@strjoin, {formats.ext}, {", "}, + "UniformOutput", false); + cols_length(1) = max (max (cellfun (@numel, extensions)), cols_length(1)); + headers{1} = postpad (headers{1}, cols_length(1), " "); + + ## Print the headers + disp (strjoin (headers, " | ")); + under_headers = cellfun (@(x) repmat ("-", 1, numel (x)), headers, + "UniformOutput", false); + disp (strjoin (under_headers, "-+-")); + + template = strjoin (arrayfun (@(x) sprintf ("%%-%is", x), cols_length, + "UniformOutput", false), " | "); + + ## Print the function handle for this things won't be a pretty table. So + ## instead we replace them with "yes" or "no", based on the support it has. + yes_no_cols = cat (2, {formats.isa}(:), {formats.info}(:), {formats.read}(:), + {formats.write}(:), {formats.alpha}(:)); + empty = cellfun (@isempty, yes_no_cols); + yes_no_cols(empty) = "no"; + yes_no_cols(! empty) = "yes"; + + descriptions = {formats.description}; + table = cat (2, extensions(:), yes_no_cols, descriptions(:)); + printf ([template "\n"], table'{:}); + +endfunction + ## When imread or imfinfo are called, the file must exist or the ## function defined by imformats will never be called. Because ## of this, we must create a file for the tests to work. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/io/strread.m --- a/scripts/io/strread.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/io/strread.m Sat May 30 05:39:47 2015 -0400 @@ -352,7 +352,7 @@ ## Remove comments in str if (comment_flag) ## Expand 'eol_char' here, after option processing which may have set value - comment_end = regexprep (comment_end, "eol_char", eol_char); + comment_end = strrep (comment_end, "eol_char", eol_char); cstart = strfind (str, comment_start); cstop = strfind (str, comment_end); ## Treat end of string as additional comment stop diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/io/textread.m --- a/scripts/io/textread.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/io/textread.m Sat May 30 05:39:47 2015 -0400 @@ -144,7 +144,6 @@ if (varargin{headerlines + 1} > 0) fskipl (fid, varargin{headerlines + 1}); varargin(headerlines:headerlines+1) = []; - nargin = nargin - 2; elseif (varargin{headerlines + 1} < 0) warning ("textread: negative headerline value ignored"); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/duplication_matrix.m --- a/scripts/linear-algebra/duplication_matrix.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/duplication_matrix.m Sat May 30 05:39:47 2015 -0400 @@ -82,7 +82,7 @@ d((j - 1) * n + i, count + i) = 1; d((i - 1) * n + j, count + i) = 1; endfor - count = count + n - j; + count += n - j; endfor endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/housh.m --- a/scripts/linear-algebra/housh.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/housh.m Sat May 30 05:39:47 2015 -0400 @@ -72,7 +72,7 @@ housv = x; m = max (abs (housv)); if (m != 0.0) - housv = housv / m; + housv /= m; alpha = norm (housv); if (alpha > z) beta = 1.0 / (alpha * (alpha + abs (housv(j)))); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/krylov.m --- a/scripts/linear-algebra/krylov.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/krylov.m Sat May 30 05:39:47 2015 -0400 @@ -209,7 +209,7 @@ for i = 1:nu hv = U(:,i); av = alpha(i); - V = V - av*hv*(hv'*V); + V -= av*hv*(hv'*V); H(i,nu-columns(V)+(1:columns(V))) = V(pivot_vec(i),:); endfor diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/logm.m --- a/scripts/linear-algebra/logm.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/logm.m Sat May 30 05:39:47 2015 -0400 @@ -86,7 +86,7 @@ while (k < opt_iters) tau = norm (s - eye (size (s)),1); if (tau <= theta (7)) - p = p + 1; + p += 1; j(1) = find (tau <= theta, 1); j(2) = find (tau / 2 <= theta, 1); if (j(1) - j(2) <= 1 || p == 2) @@ -94,7 +94,7 @@ break endif endif - k = k + 1; + k += 1; s = sqrtm (s); endwhile @@ -102,7 +102,7 @@ warning ("logm: maximum number of square roots exceeded; results may still be accurate"); endif - s = s - eye (size (s)); + s -= eye (size (s)); if (m > 1) s = logm_pade_pf (s, m); @@ -136,7 +136,7 @@ [nodes, wts] = gauss_legendre (m); ## Convert from [-1,1] to [0,1]. nodes = (nodes+1)/2; - wts = wts/2; + wts /= 2; n = length (A); s = zeros (n); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/normest.m --- a/scripts/linear-algebra/normest.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/normest.m Sat May 30 05:39:47 2015 -0400 @@ -68,7 +68,7 @@ if (normx == 0) x = rand (ncols, 1); else - x = x / normx; + x /= normx; endif y = A' * x; n = norm (y); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/linear-algebra/onenormest.m --- a/scripts/linear-algebra/onenormest.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/linear-algebra/onenormest.m Sat May 30 05:39:47 2015 -0400 @@ -133,7 +133,7 @@ ## Initial test vectors X. X = rand (n, t); - X = X ./ (ones (n,1) * sum (abs (X), 1)); + X ./= ones (n,1) * sum (abs (X), 1); ## Track if a vertex has been visited. been_there = zeros (n, 1); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/optimization/fminsearch.m --- a/scripts/optimization/fminsearch.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/optimization/fminsearch.m Sat May 30 05:39:47 2015 -0400 @@ -265,14 +265,14 @@ vr = (1 + alpha)*vbar - alpha*V(:,n+1); x(:) = vr; fr = dirn * feval (fun,x,varargin{:}); - nf = nf + 1; + nf += 1; vk = vr; fk = fr; how = "reflect, "; if (fr > f(n)) if (fr > f(1)) ve = gamma*vr + (1-gamma)*vbar; x(:) = ve; fe = dirn * feval (fun,x,varargin{:}); - nf = nf + 1; + nf += 1; if (fe > f(1)) vk = ve; fk = fe; @@ -289,7 +289,7 @@ vc = beta*vt + (1-beta)*vbar; x(:) = vc; fc = dirn * feval (fun,x,varargin{:}); - nf = nf + 1; + nf += 1; if (fc > f(n)) vk = vc; fk = fc; how = "contract,"; @@ -299,11 +299,11 @@ x(:) = V(:,j); f(j) = dirn * feval (fun,x,varargin{:}); endfor - nf = nf + n-1; + nf += n-1; vk = (V(:,1) + V(:,n+1))/2; x(:) = vk; fk = dirn * feval (fun,x,varargin{:}); - nf = nf + 1; + nf += 1; how = "shrink, "; endif endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/optimization/lsqnonneg.m --- a/scripts/optimization/lsqnonneg.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/optimization/lsqnonneg.m Sat May 30 05:39:47 2015 -0400 @@ -144,7 +144,7 @@ x += alpha*(xx - x); ## LH11: move from P to Z all X == 0. ## This corresponds to those indices where minimum of sf is attained. - idx = idx (sf == alpha); + idx = idx(sf == alpha); p(idx) = []; if (useqr) ## update the QR factorization. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/optimization/qp.m --- a/scripts/optimization/qp.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/optimization/qp.m Sat May 30 05:39:47 2015 -0400 @@ -237,13 +237,13 @@ tmprow(i) = 1; A = [A;tmprow]; b = [b; 0.5*(lb(i) + ub(i))]; - n_eq = n_eq + 1; + n_eq += 1; else tmprow = zeros (1,n); tmprow(i) = 1; Ain = [Ain; tmprow; -tmprow]; bin = [bin; lb(i); -ub(i)]; - n_in = n_in + 2; + n_in += 2; endif endfor endif @@ -281,12 +281,12 @@ tmprow = A_in(i,:); A = [A;tmprow]; b = [b; 0.5*(A_lb(i) + A_ub(i))]; - n_eq = n_eq + 1; + n_eq += 1; else tmprow = A_in(i,:); Ain = [Ain; tmprow; -tmprow]; bin = [bin; A_lb(i); -A_ub(i)]; - n_in = n_in + 2; + n_in += 2; endif endfor endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/appearance/annotation.m --- a/scripts/plot/appearance/annotation.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/appearance/annotation.m Sat May 30 05:39:47 2015 -0400 @@ -1096,7 +1096,7 @@ ## the vertical alignment of the arrow. ang = angle (complex (pos(3), pos(4))); - rot = rot / 180 * pi; + rot *= pi / 180; [~, pt] = min (abs ((-pi:pi/4:pi) - ang)); pt -= floor (rot / (pi/4)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/appearance/axis.m --- a/scripts/plot/appearance/axis.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/appearance/axis.m Sat May 30 05:39:47 2015 -0400 @@ -375,13 +375,13 @@ if (all (xlim == 0)) xlim = eps () * [-1 1]; elseif (diff (xlim == 0)) - xlim = xlim .* (1 + eps () * [-1, 1]); + xlim .*= (1 + eps () * [-1, 1]); endif ylim = __get_tight_lims__ (ca, "y"); if (all (ylim == 0)) ylim = eps () * [-1 1]; elseif (diff (ylim == 0)) - ylim = ylim .* (1 + eps () * [-1, 1]); + ylim .*= (1 + eps () * [-1, 1]); endif set (ca, "xlim", xlim, "ylim", ylim) nd = __calc_dimensions__ (ca); @@ -391,7 +391,7 @@ if (all (zlim == 0)) zlim = eps () * [-1 1]; elseif (diff (zlim == 0)) - zlim = zlim .* (1 + eps () * [-1, 1]); + zlim .*= (1 + eps () * [-1, 1]); endif set (ca, "zlim", zlim); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/appearance/legend.m --- a/scripts/plot/appearance/legend.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/appearance/legend.m Sat May 30 05:39:47 2015 -0400 @@ -715,7 +715,7 @@ ## This implies that a change in fontsize should trigger a listener ## to update the legend. The "2" was determined using a long legend ## key in the absence of any subplots. - gnuplot_offset = gnuplot_offset - 2 * fontsize; + gnuplot_offset -= 2 * fontsize; else gnuplot_offset = 0; endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/appearance/specular.m --- a/scripts/plot/appearance/specular.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/appearance/specular.m Sat May 30 05:39:47 2015 -0400 @@ -88,7 +88,7 @@ ## Allow postive values only retval(retval < 0) = 0; - retval = retval .^ se; + retval .^= se; endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/colorbar.m --- a/scripts/plot/draw/colorbar.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/colorbar.m Sat May 30 05:39:47 2015 -0400 @@ -398,48 +398,48 @@ switch (cbox) case "northoutside" origin = pos(1:2) + [0., 0.9] .* sz + [1, -1] .* off; - sz = sz .* [1.0, 0.06]; + sz .*= [1.0, 0.06]; pos(4) = 0.8 * pos(4); mirr = true; vertical = false; case "north" origin = pos(1:2) + [0.05, 0.9] .* sz + [1, -1] .* off; - sz = sz .* [1.0, 0.06] * 0.9; + sz .*= [1.0, 0.06] * 0.9; mirr = false; vertical = false; case "southoutside" origin = pos(1:2) + off; - sz = sz .* [1.0, 0.06]; + sz .*= [1.0, 0.06]; pos(2) = pos(2) + pos(4) * 0.2; pos(4) = 0.8 * pos(4); mirr = false; vertical = false; case "south" origin = pos(1:2) + [0.05, 0.05] .* sz + off; - sz = sz .* [1.0, 0.06] * 0.9; + sz .*= [1.0, 0.06] * 0.9; mirr = true; vertical = false; case "eastoutside" origin = pos(1:2) + [0.9, 0] .* sz + [-1, 1] .* off; - sz = sz .* [0.06, 1.0]; + sz .*= [0.06, 1.0]; pos(3) = 0.8 * pos(3); mirr = true; vertical = true; case "east" origin = pos(1:2) + [0.9, 0.05] .* sz + [-1, 1] .* off; - sz = sz .* [0.06, 1.0] * 0.9; + sz .*= [0.06, 1.0] * 0.9; mirr = false; vertical = true; case "westoutside" origin = pos(1:2) + off; - sz = sz .* [0.06, 1.0]; + sz .*= [0.06, 1.0]; pos(1) = pos(1) + pos(3) * 0.2; pos(3) = 0.8 * pos(3); mirr = false; vertical = true; case "west" origin = pos(1:2) + [0.05, 0.05] .* sz + off; - sz = sz .* [0.06, 1.0] .* 0.9; + sz .*= [0.06, 1.0] .* 0.9; mirr = true; vertical = true; endswitch diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/hist.m --- a/scripts/plot/draw/hist.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/hist.m Sat May 30 05:39:47 2015 -0400 @@ -101,7 +101,7 @@ if (nargin == 1 || ischar (varargin{iarg})) n = 10; x = [0.5:n]'/n; - x = x * (max_val - min_val) + ones (size (x)) * min_val; + x = (max_val - min_val) * x + min_val * ones (size (x)); else ## nargin is either 2 or 3 x = varargin{iarg++}; @@ -111,7 +111,7 @@ error ("hist: number of bins NBINS must be positive"); endif x = [0.5:n]'/n; - x = x * (max_val - min_val) + ones (size (x)) * min_val; + x = (max_val - min_val) * x + min_val * ones (size (x)); elseif (isreal (x)) if (isvector (x)) x = x(:); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/plotmatrix.m --- a/scripts/plot/draw/plotmatrix.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/plotmatrix.m Sat May 30 05:39:47 2015 -0400 @@ -138,7 +138,7 @@ have_line_spec = true; linespec = varargin(i); varargin(i) = []; - nargin = nargin - 1; + nargin -= 1; break; else print_usage ("plotmatrix"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/private/__contour__.m --- a/scripts/plot/draw/private/__contour__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/private/__contour__.m Sat May 30 05:39:47 2015 -0400 @@ -28,40 +28,42 @@ linespec.color = "auto"; linespec.linestyle = "-"; - for i = 3:2:nargin - arg = varargin{i}; - if (ischar (arg) || iscellstr (arg)) + opts = {}; + i = 3; + while (i <= length (varargin)) + if (ischar (varargin{i}) || iscellstr (varargin{i})) + arg = varargin{i}; + if (i < length (varargin)) + if (strcmpi (arg, "fill")) + filled = varargin{i+1}; + varargin(i:i+1) = []; + continue; + elseif (strcmpi (arg, "linecolor")) + linespec.color = varargin{i+1}; + varargin(i:i+1) = []; + continue; + endif + endif + [lspec, valid] = __pltopt__ ("__contour__", arg, false); if (valid) - have_line_spec = true; varargin(i) = []; - linespec = lspec; - if (isempty (linespec.color)) - linespec.color = "auto"; + if (! isempty (lspec.color)) + linespec.color = lspec.color; + endif + if (! isempty (lspec.linestyle)) + linespec.linestyle = lspec.linestyle; endif - if (isempty (linespec.linestyle)) - linespec.linestyle = "-"; + else # unrecognized option, pass unmodified in opts cell array + if (i < length (varargin)) + opts(end+(1:2)) = varargin(i:i+1); + varargin(i:i+1) = []; + else + error ("__contour__: Uneven number of PROP/VAL pairs"); endif - break; endif - endif - endfor - opts = {}; - i = 3; - while (i < length (varargin)) - if (ischar (varargin{i})) - if (strcmpi (varargin{i}, "fill")) - filled = varargin{i+1}; - varargin(i:i+1) = []; - elseif (strcmpi (varargin{i}, "linecolor")) - linespec.color = varargin{i+1}; - varargin(i:i+1) = []; - else - opts(end+(1:2)) = varargin(i:i+1); - varargin(i:i+1) = []; - endif - else + else # skip numeric arguments i++; endif endwhile diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/private/__stem__.m --- a/scripts/plot/draw/private/__stem__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/private/__stem__.m Sat May 30 05:39:47 2015 -0400 @@ -192,7 +192,7 @@ else caller = "stem"; endif - nargin = nargin - 1; # account for have_z argument + nargin = nargin () - 1; # account for have_z argument num_numeric = find (cellfun ("isclass", varargin, "char"), 1) - 1; if (isempty (num_numeric)) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/draw/surfnorm.m --- a/scripts/plot/draw/surfnorm.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/draw/surfnorm.m Sat May 30 05:39:47 2015 -0400 @@ -41,7 +41,13 @@ ## ## If output arguments are requested then the components of the normal ## vectors are returned in @var{nx}, @var{ny}, and @var{nz} and no plot is -## made. +## made. The normal vectors are unnormalized (magnitude != 1). To normalize, +## use +## +## @example +## mag = sqrt (nx.^2 + ny.^2 + nz.^2); +## nx ./= len; ny ./= len; nz ./= len; +## @end example ## ## An example of the use of @code{surfnorm} is ## @@ -50,10 +56,14 @@ ## @end example ## ## Algorithm: The normal vectors are calculated by taking the cross product -## of the diagonals of each of the quadrilaterals in the meshgrid to find the -## normal vectors of the centers of these quadrilaterals. The four nearest -## normal vectors to the meshgrid points are then averaged to obtain the -## normal to the surface at the meshgridded points. +## of the diagonals of each of the quadrilateral faces in the meshgrid to find +## the normal vectors at the center of each face. Next, for each meshgrid +## point the four nearest normal vectors are averaged to obtain the final +## normal to the surface at the meshgrid point. +## +## For surface objects, the @qcode{"VertexNormals"} property contains +## equivalent information, except possibly near the boundary of the surface +## where different interpolation schemes may yield slightly different values. ## ## @seealso{isonormals, quiver3, surf, meshgrid} ## @end deftypefn @@ -84,6 +94,7 @@ error ("surfnorm: X, Y, and Z must have the same dimensions"); endif + ## FIXME: Matlab uses a bicubic interpolation, not linear, along the boundary. ## Do a linear extrapolation for mesh points on the boundary so that the mesh ## is increased by 1 on each side. This allows each original meshgrid point ## to be surrounded by four quadrilaterals and the same calculation can be @@ -116,14 +127,6 @@ nz = (w.z(1:end-1,1:end-1) + w.z(1:end-1,2:end) + w.z(2:end,1:end-1) + w.z(2:end,2:end)) / 4; - ## FIXME: According to Matlab documentation the vertex normals - ## returned are not normalized. - ## Normalize the normal vectors - len = sqrt (nx.^2 + ny.^2 + nz.^2); - nx ./= len; - ny ./= len; - nz ./= len; - if (nargout == 0) oldfig = []; if (! isempty (hax)) @@ -137,21 +140,20 @@ unwind_protect set (hax, "nextplot", "add"); - ## FIXME: Scale unit normals by data aspect ratio in order for - ## normals to appear correct. - ##daratio = daspect (hax); - ##daspect ("manual"); - ##len = norm (daratio); - ## This assumes an even meshgrid which isn't a great assumption - ##dx = x(1,2) - x(1,1); - ##dy = y(2,1) - y(1,1); - ##nx *= daratio(1); - ##ny *= daratio(2); - ##nz *= daratio(3); - ##len = sqrt (nx.^2 + ny.^2 + nz.^2); - ##nx ./= len; - ##ny ./= len; - ##nz ./= len; + ## Normalize the normal vectors + nmag = sqrt (nx.^2 + ny.^2 + nz.^2); + + ## And correct for the aspect ratio of the display + daratio = daspect (hax); + damag = sqrt (sumsq (daratio)); + + ## FIXME: May also want to normalize the vectors relative to the size + ## of the diagonal. + + nx ./= nmag / (daratio(1)^2 / damag); + ny ./= nmag / (daratio(2)^2 / damag); + nz ./= nmag / (daratio(3)^2 / damag); + plot3 ([x(:).'; x(:).' + nx(:).' ; NaN(size(x(:).'))](:), [y(:).'; y(:).' + ny(:).' ; NaN(size(y(:).'))](:), [z(:).'; z(:).' + nz(:).' ; NaN(size(z(:).'))](:), @@ -177,10 +179,10 @@ %!demo %! clf; %! colormap ('default'); -%! surfnorm (peaks (32)); -%! shading interp; +%! surfnorm (peaks (19)); +%! shading faceted; %! title ({'surfnorm() shows surface and normals at each vertex', ... -%! 'peaks() function with 32 faces'}); +%! 'peaks() function with 19 faces'}); %!demo %! clf; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/__actual_axis_position__.m --- a/scripts/plot/util/__actual_axis_position__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/__actual_axis_position__.m Sat May 30 05:39:47 2015 -0400 @@ -67,13 +67,13 @@ endif orig_aspect_ratio_2d = pos_in_pixels(3:4); rel_aspect_ratio_2d = aspect_ratio_2d ./ orig_aspect_ratio_2d; - rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d); + rel_aspect_ratio_2d ./= max (rel_aspect_ratio_2d); if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2)); dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3); - pos_in_pixels = pos_in_pixels + dx*[0.5, 0.0, -1.0, 0.0]; + pos_in_pixels += dx*[0.5, 0.0, -1.0, 0.0]; elseif (rel_aspect_ratio_2d(1) > rel_aspect_ratio_2d(2)) dy = (1.0 - rel_aspect_ratio_2d(2)) * pos_in_pixels(4); - pos_in_pixels = pos_in_pixels + dy*[0.0, 0.5, 0.0, -1.0]; + pos_in_pixels += dy*[0.0, 0.5, 0.0, -1.0]; endif pos = pos_in_pixels ./ fig_position([3, 4, 3, 4]); elseif (strcmp (get (axis_obj.parent, "__graphics_toolkit__"), "gnuplot") diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/__gnuplot_drawnow__.m --- a/scripts/plot/util/__gnuplot_drawnow__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/__gnuplot_drawnow__.m Sat May 30 05:39:47 2015 -0400 @@ -185,8 +185,8 @@ || any (strcmp (term, {"canvas", "emf", "gif", "jpeg", ... "pbm", "png", "pngcairo", "svg"})))) ## Convert to inches - gnuplot_pos = gnuplot_pos / 72; - gnuplot_size = gnuplot_size / 72; + gnuplot_pos /= 72; + gnuplot_size /= 72; endif if (all (gnuplot_size > 0)) terminals_with_size = {"canvas", "emf", "epslatex", "fig", ... diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/findobj.m --- a/scripts/plot/util/findobj.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/findobj.m Sat May 30 05:39:47 2015 -0400 @@ -99,7 +99,7 @@ if (ischar (varargin{n1})) if (strcmpi (varargin{n1}, "flat")) depth = 0; - n1 = n1 + 1; + n1 += 1; endif else error ("findobj: properties and options must be strings"); @@ -133,32 +133,32 @@ if (ischar (args{na})) if (strcmpi (args{na}, "-property")) if (na + 1 <= numel (args)) - na = na + 1; + na += 1; property(np) = 1; pname{np} = args{na}; - na = na + 1; + na += 1; pvalue{np} = []; - np = np + 1; + np += 1; else error ("findobj: inconsistent number of arguments"); endif elseif (strcmpi (args{na}, "-regexp")) if (na + 2 <= numel (args)) regularexpression(np) = 1; - na = na + 1; + na += 1; pname{np} = args{na}; - na = na + 1; + na += 1; pvalue{np} = args{na}; - na = na + 1; - np = np + 1; + na += 1; + np += 1; else error ("findobj: inconsistent number of arguments"); endif elseif (strcmpi (args{na}, "-depth")) if (na + 1 <= numel (args)) - na = na + 1; + na += 1; depth = args{na}; - na = na + 1; + na += 1; else error ("findobj: inconsistent number of arguments"); endif @@ -166,14 +166,14 @@ ## Parameter/value pairs. if (na + 1 <= numel (args)) pname{np} = args{na}; - na = na + 1; + na += 1; pvalue{np} = args{na}; - na = na + 1; + na += 1; if (na <= numel (args)) if (ischar (args{na})) if (any (strcmpi (args{na}, operatorprecedence))) logicaloperator{np} = args{na}(2:end); - na = na+1; + na += 1; endif else error ("findobj: properties and options must be strings"); @@ -181,7 +181,7 @@ else logicaloperator{np} = "and"; endif - np = np + 1; + np += 1; else error ("findobj: inconsistent number of arguments"); endif @@ -189,7 +189,7 @@ if (strcmpi (args{na}, "-not")) extranegation(np) = true; endif - na = na + 1; + na += 1; endif else error ("findobj: properties and options must be strings"); @@ -211,7 +211,7 @@ endfor handles = children; h = [h; children]; - idepth = idepth + 1; + idepth += 1; endwhile if (numpairs > 0) @@ -267,7 +267,7 @@ match(:,np+1)); logicaloperator(np+1) = []; match(:,np+1) = []; - numpairs = numpairs - 1; + numpairs -= 1; endif if (numpairs < 2) break; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/ginput.m --- a/scripts/plot/util/ginput.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/ginput.m Sat May 30 05:39:47 2015 -0400 @@ -69,12 +69,15 @@ ginput_accumulator (0, 0, 0, 0); # initialize accumulator orig_windowbuttondownfcn = get (fig, "windowbuttondownfcn"); - orig_ginput_keypressfcn = get (fig, "keypressfcn"); + orig_keypressfcn = get (fig, "keypressfcn"); + orig_closerequestfcn = get (fig, "closerequestfcn"); unwind_protect set (fig, "windowbuttondownfcn", @ginput_windowbuttondownfcn); set (fig, "keypressfcn", @ginput_keypressfcn); + set (fig, "closerequestfcn", {@ginput_closerequestfcn, + orig_closerequestfcn}); do if (strcmp (toolkit, "fltk")) @@ -95,8 +98,11 @@ endif unwind_protect_cleanup - set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn); - set (fig, "keypressfcn", orig_ginput_keypressfcn); + if (isfigure (fig)) + ## Only execute if window still exists + set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn); + set (fig, "keypressfcn", orig_keypressfcn); + endif end_unwind_protect varargout = {x, y, button}; @@ -123,12 +129,12 @@ endfunction -function ginput_windowbuttondownfcn (src, button) +function ginput_windowbuttondownfcn (~, button) point = get (gca (), "currentpoint"); ginput_accumulator (1, point(1,1), point(1,2), button); endfunction -function ginput_keypressfcn (src, evt) +function ginput_keypressfcn (~, evt) point = get (gca (), "currentpoint"); if (strcmp (evt.Key, "return")) ## Enter key stops ginput. @@ -141,6 +147,11 @@ endif endfunction +function ginput_closerequestfcn (hfig, ~, orig_closerequestfcn) + ginput_accumulator (2, NaN, NaN, NaN); # Stop ginput + feval (orig_closerequestfcn); # Close window with original fcn +endfunction + ## Remove from test statistics. No real tests possible. %!test diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/print.m --- a/scripts/plot/util/print.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/print.m Sat May 30 05:39:47 2015 -0400 @@ -412,7 +412,7 @@ endif if (! isempty (opts.scalefontsize) && ! opts.scalefontsize != 1) ## This is done to work around the bbox being whole numbers. - fontsize = fontsize * opts.scalefontsize; + fontsize *= opts.scalefontsize; endif ## FIXME: legend child objects need to be acted on first. ## or legend fontsize callback will destroy them. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/private/__gnuplot_get_var__.m --- a/scripts/plot/util/private/__gnuplot_get_var__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/private/__gnuplot_get_var__.m Sat May 30 05:39:47 2015 -0400 @@ -52,8 +52,7 @@ if (use_mkfifo) gpin_name = tempname (); - ## Mode: 0600 == 6*8*8 - [err, msg] = mkfifo (gpin_name, 6*8*8); + [err, msg] = mkfifo (gpin_name, 600); if (err) error ("__gnuplot_get_var__: Can not make FIFO (%s)", msg); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/private/__gnuplot_ginput__.m --- a/scripts/plot/util/private/__gnuplot_ginput__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/private/__gnuplot_ginput__.m Sat May 30 05:39:47 2015 -0400 @@ -63,8 +63,7 @@ if (use_mkfifo) gpin_name = tempname (); - ##Mode: 6*8*8 == 0600 - [err, msg] = mkfifo (gpin_name, 6*8*8); + [err, msg] = mkfifo (gpin_name, 600); if (err) error ("ginput: Can not open fifo (%s)", msg); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/private/__go_draw_axes__.m --- a/scripts/plot/util/private/__go_draw_axes__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/private/__go_draw_axes__.m Sat May 30 05:39:47 2015 -0400 @@ -414,7 +414,7 @@ ## preserved the original order. [jnk, k] = setdiff (kids, [axis_obj.xlabel; axis_obj.ylabel; ... axis_obj.zlabel; axis_obj.title]); - kids = kids (sort (k)); + kids = kids(sort (k)); if (nd == 3) fputs (plot_stream, "set parametric;\n"); @@ -1631,7 +1631,7 @@ fputs (plot_stream, "set style data lines;\n"); cmap = [cmap; addedcmap]; - cmap_sz = cmap_sz + rows (addedcmap); + cmap_sz += rows (addedcmap); if (mono == false && length (cmap) > 0) fprintf (plot_stream, "set palette positive color model RGB maxcolors %i;\n", @@ -2345,12 +2345,12 @@ ## FIXME: The symbol font doesn't seem to support bold or italic ##if (bld) ## if (it) - ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); + ## g = strrep (g, '/Symbol', '/Symbol-bolditalic'); ## else - ## g = regexprep (g, '/Symbol', '/Symbol-bold'); + ## g = strrep (g, '/Symbol', '/Symbol-bold'); ## endif ##elseif (it) - ## g = regexprep (g, '/Symbol', '/Symbol-italic'); + ## g = strrep (g, '/Symbol', '/Symbol-italic'); ##endif str = [str(1:s(i) - 1) g str(e(i) + 1:end)]; elseif (strncmp (f, "rm", 2)) @@ -2406,12 +2406,12 @@ ## FIXME: The symbol font doesn't seem to support bold or italic ##if (bld) ## if (it) - ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); + ## g = strrep (g, '/Symbol', '/Symbol-bolditalic'); ## else - ## g = regexprep (g, '/Symbol', '/Symbol-bold'); + ## g = strrep (g, '/Symbol', '/Symbol-bold'); ## endif ##elseif (it) - ## g = regexprep (g, '/Symbol', '/Symbol-italic'); + ## g = strrep (g, '/Symbol', '/Symbol-italic'); ##endif str = [str(1:s(i) - 1) g str(s(i) + length (flds{j}) + 1:end)]; break; @@ -2449,7 +2449,7 @@ si++; endif endwhile - l1 = l1 (min (length (l1), si)); + l1 = l1(min (length (l1), si)); if (s(i) + l1 + 1 == s(i+1)) if (str(s(i + 1) + p + 1) == "{") s2 = strfind (str(s(i + 1) + p + 2:end),'{'); @@ -2466,7 +2466,7 @@ si++; endif endwhile - l2 = l2 (min (length (l2), si)); + l2 = l2(min (length (l2), si)); if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= length_string (str(s(i+1)+p+2:s(i+1)+p+l2-1))) ## Shortest already first! @@ -2507,7 +2507,7 @@ l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}')); m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches'); if (! isempty (m)) - l = l - sum (cellfun ("length", m)); + l -= sum (cellfun ("length", m)); endif endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/private/__print_parse_opts__.m --- a/scripts/plot/util/private/__print_parse_opts__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/private/__print_parse_opts__.m Sat May 30 05:39:47 2015 -0400 @@ -495,7 +495,7 @@ endif n = 0; while (n < numel (gs_binaries) && isempty (ghostscript_binary)) - n = n + 1; + n += 1; ghostscript_binary = file_in_path (getenv ("PATH"), gs_binaries{n}); endwhile if (warn_on_no_ghostscript && isempty (ghostscript_binary)) @@ -529,7 +529,7 @@ endif n = 0; while (n < numel (binaries) && isempty (data.(binary).bin)) - n = n + 1; + n += 1; data.(binary).bin = file_in_path (getenv ("PATH"), binaries{n}); endwhile if (isempty (data.(binary).bin) && data.(binary).warn_on_absence) @@ -574,7 +574,7 @@ endif if (strcmp (paperunits, "normalized")) - paperposition = paperposition .* papersize([1,2,1,2]); + paperposition .*= papersize([1,2,1,2]); else paperposition = convert2points (paperposition, paperunits); endif @@ -611,9 +611,9 @@ function value = convert2points (value, units) switch (units) case "inches" - value = value * 72; + value *= 72; case "centimeters" - value = value * 72 / 2.54; + value *= 72 / 2.54; case "normalized" error ("print:customnormalized", "print.m: papersize=='' and paperunits='normalized' may not be combined"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/plot/util/rotate.m --- a/scripts/plot/util/rotate.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/plot/util/rotate.m Sat May 30 05:39:47 2015 -0400 @@ -111,7 +111,7 @@ origin = [a, b, c]; endif - direction = direction / norm (direction); + direction /= norm (direction); u = direction(1); v = direction(2); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/polynomial/pchip.m --- a/scripts/polynomial/pchip.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/polynomial/pchip.m Sat May 30 05:39:47 2015 -0400 @@ -116,7 +116,7 @@ del2 = (d2 - delta) / h; c3 = del1 + del2; c2 = -c3 - del1; - c3 = c3 / h; + c3 /= h; coeffs = cat (3, c3, c2, d1, f1); ret = mkpp (x, coeffs, szy(1:end-1)); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/polynomial/polyaffine.m --- a/scripts/polynomial/polyaffine.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/polynomial/polyaffine.m Sat May 30 05:39:47 2015 -0400 @@ -56,7 +56,7 @@ ## Scale. if (mu(2) != 1) - g = g ./ (mu(2) .^ (lf-1:-1:0)); + g ./= mu(2) .^ (lf-1:-1:0); endif ## Translate. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/polynomial/polyder.m --- a/scripts/polynomial/polyder.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/polynomial/polyder.m Sat May 30 05:39:47 2015 -0400 @@ -69,8 +69,8 @@ endif ## move all the gain into the numerator - q = q/d(1); - d = d/d(1); + q /= d(1); + d /= d(1); endif else lp = numel (p); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/polynomial/private/__splinefit__.m --- a/scripts/polynomial/private/__splinefit__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/polynomial/private/__splinefit__.m Sat May 30 05:39:47 2015 -0400 @@ -151,7 +151,7 @@ % Solve constraints [Z,u0] = solvecon(B,constr); % Solve Min norm(u*A-y), subject to u*B = yc - y = y - u0*A; + y -= u0*A; A = Z*A; v = lsqsolve(A,y,beta); u = u0 + v*Z; @@ -487,7 +487,7 @@ end % Reduce number of pieces -pieces = pieces - 2*deg; +pieces -= 2*deg; % Sort coefficients by interval number ii = [n*(1:pieces); deg*ones(deg,pieces)]; @@ -517,7 +517,7 @@ B0 = zeros(n,nx); for k = 1:size(cc,1) if any(cc(k,:)) - B0 = B0 + repmat(cc(k,:),n,1).*ppval(base,xc); + B0 += repmat(cc(k,:),n,1).*ppval(base,xc); end % Differentiate base coefs = base.coefs(:,1:n-k); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/polynomial/residue.m --- a/scripts/polynomial/residue.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/polynomial/residue.m Sat May 30 05:39:47 2015 -0400 @@ -170,8 +170,8 @@ a = polyreduce (a); b = polyreduce (b); - b = b / a(1); - a = a / a(1); + b /= a(1); + a /= a(1); la = length (a); lb = length (b); @@ -329,13 +329,13 @@ endfor pn = deconv (pden, pm); pn = r(n) * pn; - pnum = pnum + prepad (pn, N+1, 0, 2); + pnum += prepad (pn, N+1, 0, 2); endfor ## Add the direct term. if (numel (k)) - pnum = pnum + conv (pden, k); + pnum += conv (pden, k); endif ## Check for leading zeros and trim the polynomial coefficients. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/arch_fit.m --- a/scripts/signal/arch_fit.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/arch_fit.m Sat May 30 05:39:47 2015 -0400 @@ -96,17 +96,17 @@ tmp = esq ./ h.^2 - 1 ./ h; s = 1 ./ h(1:T-p); for j = 1 : p; - s = s - a(j+1) * tmp(j+1:T-p+j); + s -= a(j+1) * tmp(j+1:T-p+j); endfor r = 1 ./ h(1:T-p); for j = 1:p; - r = r + 2 * h(j+1:T-p+j).^2 .* esq(1:T-p); + r += 2 * h(j+1:T-p+j).^2 .* esq(1:T-p); endfor r = sqrt (r); X_tilde = x(1:T-p, :) .* (r * ones (1,k)); e_tilde = e(1:T-p) .*s ./ r; delta_b = inv (X_tilde' * X_tilde) * X_tilde' * e_tilde; - b = b + gamma * delta_b; + b += gamma * delta_b; e = y - x * b; esq = e .^ 2; Z = autoreg_matrix (esq, p); @@ -114,7 +114,7 @@ f = esq ./ h - ones (T,1); Z_tilde = Z ./ (h * ones (1, p+1)); delta_a = inv (Z_tilde' * Z_tilde) * Z_tilde' * f; - a = a + gamma * delta_a; + a += gamma * delta_a; endfor endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/arch_rnd.m --- a/scripts/signal/arch_rnd.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/arch_rnd.m Sat May 30 05:39:47 2015 -0400 @@ -63,14 +63,14 @@ a = reshape (a, 1, la); if (la == 1) a = [a, 0]; - la = la + 1; + la += 1; endif lb = length (b); b = reshape (b, 1, lb); if (lb == 1) b = [b, 0]; - lb = lb + 1; + lb += 1; endif m = max ([la, lb]); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/bartlett.m --- a/scripts/signal/bartlett.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/bartlett.m Sat May 30 05:39:47 2015 -0400 @@ -42,7 +42,7 @@ if (m == 1) c = 1; else - m = m - 1; + m -= 1; n = fix (m / 2); c = [2*(0:n)/m, 2-2*(n+1:m)/m]'; endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/blackman.m --- a/scripts/signal/blackman.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/blackman.m Sat May 30 05:39:47 2015 -0400 @@ -60,7 +60,7 @@ if (m == 1) c = 1; else - m = m - 1; + m -= 1; k = (0 : m)' / N; c = 0.42 - 0.5 * cos (2 * pi * k) + 0.08 * cos (4 * pi * k); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/freqz.m --- a/scripts/signal/freqz.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/freqz.m Sat May 30 05:39:47 2015 -0400 @@ -152,7 +152,7 @@ k = max (length (b), length (a)); if (k > n/2 && nargout == 0) ## Ensure a causal phase response. - n = n * 2 .^ ceil (log2 (2*k/n)); + n *= 2 .^ ceil (log2 (2*k/n)); endif if (whole_region) @@ -178,8 +178,8 @@ ha = zeros (n, 1); for i = 1:N:pad_sz - hb = hb + fft (postpad (b(i:i+N-1), N))(1:n); - ha = ha + fft (postpad (a(i:i+N-1), N))(1:n); + hb += fft (postpad (b(i:i+N-1), N))(1:n); + ha += fft (postpad (a(i:i+N-1), N))(1:n); endfor endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/hamming.m --- a/scripts/signal/hamming.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/hamming.m Sat May 30 05:39:47 2015 -0400 @@ -60,7 +60,7 @@ if (m == 1) c = 1; else - m = m - 1; + m -= 1; c = 0.54 - 0.46 * cos (2 * pi * (0 : m)' / N); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/hanning.m --- a/scripts/signal/hanning.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/hanning.m Sat May 30 05:39:47 2015 -0400 @@ -60,7 +60,7 @@ if (m == 1) c = 1; else - m = m - 1; + m -= 1; c = 0.5 - 0.5 * cos (2 * pi * (0 : m)' / N); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/spectral_adf.m --- a/scripts/signal/spectral_adf.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/spectral_adf.m Sat May 30 05:39:47 2015 -0400 @@ -60,7 +60,7 @@ w = feval (win, cr, b); endif - c = c .* w; + c .*= w; retval = 2 * real (fft (c)) - c(1); retval = [(zeros (cr, 1)), retval]; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/spectral_xdf.m --- a/scripts/signal/spectral_xdf.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/spectral_xdf.m Sat May 30 05:39:47 2015 -0400 @@ -60,7 +60,7 @@ w = feval (win, xr, b); endif - x = x - sum (x) / xr; + x -= sum (x) / xr; retval = (abs (fft (x)) / xr).^2; retval = real (ifft (fft (retval) .* fft (w))); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/signal/stft.m --- a/scripts/signal/stft.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/signal/stft.m Sat May 30 05:39:47 2015 -0400 @@ -101,7 +101,7 @@ start = 1; for i = 0:num_win z(1:win_size, i+1) = x(start:start+win_size-1) .* win_coef; - start = start + inc; + start += inc; endfor y = fft (z); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/bicgstab.m --- a/scripts/sparse/bicgstab.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/bicgstab.m Sat May 30 05:39:47 2015 -0400 @@ -163,7 +163,7 @@ t = Ax (shat); omega = (s' * t) / (t' * t); - x = x + alpha * phat + omega * shat; + x += alpha * phat + omega * shat; res = s - omega * t; rho_2 = rho_1; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/cgs.m --- a/scripts/sparse/cgs.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/cgs.m Sat May 30 05:39:47 2015 -0400 @@ -147,9 +147,9 @@ ## Cache. q = Ax (p); alpha = ro / (p' * q); - x = x + alpha * p; + x += alpha * p; - res = res - alpha * q; + res -= alpha * q; relres = norm (res) / norm_b; resvec = [resvec; relres]; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/private/__sprand_impl__.m --- a/scripts/sparse/private/__sprand_impl__.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/private/__sprand_impl__.m Sat May 30 05:39:47 2015 -0400 @@ -135,7 +135,7 @@ V = Vinit; V(i, i) = cv; V(i, j) = sv; V(j, i) = -sv; V(j, j) = cv; - S = S * V; + S *= V; endif endwhile endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/qmr.m --- a/scripts/sparse/qmr.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/qmr.m Sat May 30 05:39:47 2015 -0400 @@ -181,9 +181,9 @@ for iter=1:1:maxit ## If rho0 == 0 or xi1 == 0, method fails. v = vt / rho0; - y = y / rho0; + y /= rho0; w = wt / xi1; - z = z / xi1; + z /= xi1; delta1 = z' * y; # If delta1 == 0, method fails. diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/sprandsym.m --- a/scripts/sparse/sprandsym.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/sprandsym.m Sat May 30 05:39:47 2015 -0400 @@ -41,7 +41,7 @@ [i, j] = find (tril (n)); [nr, nc] = size (n); S = sparse (i, j, randn (size (i)), nr, nc); - S = S + tril (S, -1)'; + S += tril (S, -1)'; return; endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/sparse/svds.m --- a/scripts/sparse/svds.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/sparse/svds.m Sat May 30 05:39:47 2015 -0400 @@ -162,7 +162,7 @@ b_opts.issym = true; b_sigma = sigma; if (! ischar (b_sigma)) - b_sigma = b_sigma / max_a; + b_sigma /= max_a; endif if (b_sigma == 0) @@ -225,7 +225,7 @@ endif endif - s = s * max_a; + s *= max_a; endif if (nargout < 2) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/specfun/legendre.m --- a/scripts/specfun/legendre.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/specfun/legendre.m Sat May 30 05:39:47 2015 -0400 @@ -192,7 +192,7 @@ error ('legendre: NORMALIZATION option must be "unnorm", "norm", or "sch"'); endswitch - scale = scale * ones (size (x)); + scale *= ones (size (x)); ## Based on the recurrence relation below ## m m m diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/special-matrix/gallery.m --- a/scripts/special-matrix/gallery.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/special-matrix/gallery.m Sat May 30 05:39:47 2015 -0400 @@ -595,7 +595,7 @@ error ("gallery: unknown K '%d' for chebspec matrix.", k); endswitch - n = n-1; + n -= 1; C = zeros (n+1); one = ones (n+1, 1); @@ -773,7 +773,7 @@ error ("gallery: K must be a numeric scalar for clement matrix."); endif - n = n-1; + n -= 1; x = n:-1:1; z = 1:n; @@ -1493,13 +1493,13 @@ if (k == 0) for i = 1:n-1 - d = d * prod (1:i+1) * prod (1:n-i); + d *= prod (1:i+1) * prod (1:n-i); endfor - d = d * prod (1:n+1); + d *= prod (1:n+1); elseif (k == 1) for i = 0:n-1 - d = d * prod (1:i) / prod (1:n+1+i); + d *= prod (1:i) / prod (1:n+1+i); endfor if (rem (n*(n-1)/2, 2)) d = -d; @@ -2218,7 +2218,7 @@ ## If A will be a vector if (p == 1) A = randn (m, n); - A = A / norm (A); + A /= norm (A); return; endif @@ -2339,7 +2339,7 @@ error ("gallery: N must be an integer for riemann matrix."); endif - n = n+1; + n += 1; i = (2:n)' * ones (1, n-1); j = i'; A = i .* (! rem (j, i)) - ones (n-1); @@ -2435,7 +2435,7 @@ E = 2*pi * ((1:n)' * ones (1, n) - ones (n, 1) * (1:n)); for i = 1:m - T = T + w(i) * cos (theta(i)*E); + T += w(i) * cos (theta(i)*E); endfor endfunction diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/statistics/base/gls.m --- a/scripts/statistics/base/gls.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/statistics/base/gls.m Sat May 30 05:39:47 2015 -0400 @@ -99,7 +99,7 @@ endif ## Start of algorithm - o = o^(-1/2); + o ^= -1/2; z = kron (eye (cy), x); z = o * z; y1 = o * reshape (y, ry*cy, 1); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/statistics/models/logistic_regression.m --- a/scripts/statistics/models/logistic_regression.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/statistics/models/logistic_regression.m Sat May 30 05:39:47 2015 -0400 @@ -128,16 +128,16 @@ ## maximize likelihood using Levenberg modified Newton's method iter = 0; while (abs (dl' * (d2l \ dl) / length (dl)) > tol) - iter = iter + 1; + iter += 1; tbold = tb; devold = dev; tb = tbold - d2l \ dl; [g, g1, p, dev] = logistic_regression_likelihood (y, x, tb, z, z1); if ((dev - devold) / (dl' * (tb - tbold)) < 0) - epsilon = epsilon / decr; + epsilon /= decr; else while ((dev - devold) / (dl' * (tb - tbold)) > 0) - epsilon = epsilon * incr; + epsilon *= incr; if (epsilon > 1e+15) error ("logistic_regression: epsilon too large"); endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/statistics/tests/kruskal_wallis_test.m --- a/scripts/statistics/tests/kruskal_wallis_test.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/statistics/tests/kruskal_wallis_test.m Sat May 30 05:39:47 2015 -0400 @@ -73,7 +73,7 @@ k = 0; j = 0; for i = 1 : m; - k = k + (sum (r ((j + 1) : (j + n(i))))) ^ 2 / n(i); + k += (sum (r ((j + 1) : (j + n(i))))) ^ 2 / n(i); j = j + n(i); endfor @@ -82,7 +82,7 @@ ## Adjust the result to takes ties into account. sum_ties = sum (polyval ([1, 0, -1, 0], runlength (sort (p)))); - k = k / (1 - sum_ties / (n^3 - n)); + k /= (1 - sum_ties / (n^3 - n)); df = m - 1; pval = 1 - chi2cdf (k, df); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/statistics/tests/manova.m --- a/scripts/statistics/tests/manova.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/statistics/tests/manova.m Sat May 30 05:39:47 2015 -0400 @@ -69,7 +69,7 @@ group_label = s ([1, (reshape (i, 1, k - 1) + 1)]); endif - x = x - ones (n, 1) * mean (x); + x -= ones (n, 1) * mean (x); SST = x' * x; s = zeros (1, p); @@ -77,7 +77,7 @@ for i = 1 : k; v = x (find (g == group_label (i)), :); s = sum (v); - SSB = SSB + s' * s / rows (v); + SSB += s' * s / rows (v); endfor n_b = k - 1; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/statistics/tests/wilcoxon_test.m --- a/scripts/statistics/tests/wilcoxon_test.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/statistics/tests/wilcoxon_test.m Sat May 30 05:39:47 2015 -0400 @@ -58,11 +58,11 @@ x = reshape (x, 1, n); y = reshape (y, 1, n); d = x - y; - d = d (find (d != 0)); + d = d(find (d != 0)); n = length (d); if (n > 25) r = ranks (abs (d)); - z = sum (r (find (d > 0))); + z = sum (r(find (d > 0))); z = ((z - n * (n + 1) / 4) / sqrt (n * (n + 1) * (2 * n + 1) / 24)); else error ("wilcoxon_test: implementation requires more than 25 different pairs"); diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/strings/cstrcat.m --- a/scripts/strings/cstrcat.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/strings/cstrcat.m Sat May 30 05:39:47 2015 -0400 @@ -45,14 +45,16 @@ function st = cstrcat (varargin) - if (nargin < 1) - print_usage (); - elseif (! iscellstr (varargin)) + if (nargin == 0) + ## Special because if varargin is empty, iscellstr still returns + ## true but then "[varargin{:}]" would be of class double. + st = ""; + elseif (iscellstr (varargin)) + st = [varargin{:}]; + else error ("cstrcat: expecting arguments to character strings"); endif - st = [varargin{:}]; - endfunction @@ -65,7 +67,8 @@ %!assert (cstrcat ("foo", "bar"), "foobar") %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]) +%!assert (cstrcat (), "") + ## Test input validation -%!error cstrcat () %!error cstrcat (1, 2) diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/strings/strcat.m --- a/scripts/strings/strcat.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/strings/strcat.m Sat May 30 05:39:47 2015 -0400 @@ -82,10 +82,8 @@ function st = strcat (varargin) if (nargin == 0) - print_usage (); - endif - - if (nargin == 1) + st = ""; + elseif (nargin == 1) st = varargin{1}; else ## Convert to cells of strings @@ -149,5 +147,5 @@ %!assert (strcat (1, 2), strcat (char (1), char (2))) %!assert (strcat ("", 2), strcat ([], char (2))) -%!error strcat () +%!assert (strcat (), "") diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/testfun/private/html_compare_plot_demos.m --- a/scripts/testfun/private/html_compare_plot_demos.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/testfun/private/html_compare_plot_demos.m Sat May 30 05:39:47 2015 -0400 @@ -113,7 +113,7 @@ fprintf (fid, "", ... ffn, in.column_width); else - err_fn = regexprep(ffn, ".png", ".err"); + err_fn = strrep (ffn, ".png", ".err"); if (! exist (err_fn, "file")) warning("File %s doesn't exist...", err_fn); else diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/testfun/test.m --- a/scripts/testfun/test.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/testfun/test.m Sat May 30 05:39:47 2015 -0400 @@ -609,14 +609,13 @@ fflush (__fid); endif fprintf (__fid, "%s\n", __msg); - fflush (__fid); ## Show the variable context. if (! strcmp (__type, "error") && ! strcmp (__type, "testif") && ! all (__shared == " ")) fputs (__fid, "shared variables "); eval (sprintf ("fdisp(__fid,var2struct(%s));", __shared)); - fflush (__fid); endif + fflush (__fid); endif if (! __success && ! __isxtest) __all_success = false; diff -r 3ccc2d02e64b -r 3e8c188b20a7 scripts/time/datevec.m --- a/scripts/time/datevec.m Sat May 23 10:35:40 2015 -0400 +++ b/scripts/time/datevec.m Sat May 30 05:39:47 2015 -0400 @@ -183,9 +183,9 @@ srnd = 2 .^ floor (- log2 (tmps)); s = round (86400 * fracd .* srnd) ./ srnd; h = floor (s / 3600); - s = s - 3600 * h; + s -= 3600 * h; mi = floor (s / 60); - s = s - 60 * mi; + s -= 60 * mi; endif diff -r 3ccc2d02e64b -r 3e8c188b20a7 test/Makefile.am --- a/test/Makefile.am Sat May 23 10:35:40 2015 -0400 +++ b/test/Makefile.am Sat May 30 05:39:47 2015 -0400 @@ -58,6 +58,7 @@ include bug-36025/module.mk include bug-38236/module.mk include bug-38691/module.mk +include bug-44940/module.mk include classdef/module.mk include classes/module.mk include class-concat/module.mk diff -r 3ccc2d02e64b -r 3e8c188b20a7 test/bug-44940/bug-44940.tst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-44940/bug-44940.tst Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,11 @@ +%!test +%! a = class_bug44940 (); +%! b = a; +%! c = a (); +%! a.child = 100; +%! assert (a.child, b.child) +%! assert (a.child, c.child) +%! c.child = 500; +%! assert (a.child, b.child) +%! assert (a.child, c.child) + diff -r 3ccc2d02e64b -r 3e8c188b20a7 test/bug-44940/class_bug44940.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-44940/class_bug44940.m Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,5 @@ +classdef class_bug44940 < handle + properties + child + endproperties +endclassdef diff -r 3ccc2d02e64b -r 3e8c188b20a7 test/bug-44940/module.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-44940/module.mk Sat May 30 05:39:47 2015 -0400 @@ -0,0 +1,5 @@ +bug_44940_FCN_FILES = \ + bug-44940/bug-44940.tst \ + bug-44940/class_bug44940.m + +FCN_FILES += $(bug_44940_FCN_FILES)