changeset 24301:1523c409b2d4

maint: merge stable to default.
author Rik <rik@octave.org>
date Thu, 23 Nov 2017 13:57:42 -0800
parents 9a1b193ddd01 (current diff) 117107eed917 (diff)
children a9db5eed8fce
files libgui/src/octave-qt-link.cc libgui/src/workspace-view.cc liboctave/array/CMatrix.cc liboctave/array/dMatrix.cc liboctave/array/fCMatrix.cc liboctave/array/fMatrix.cc
diffstat 6 files changed, 138 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/octave-qt-link.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/libgui/src/octave-qt-link.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -369,8 +369,8 @@
 
   QString title = tr ("Change Directory or Add Directory to Load Path");
 
-  QString cd_txt = tr ("Change Directory");
-  QString addpath_txt = tr ("Add Directory to Load Path");
+  QString cd_txt = tr ("&Change Directory");
+  QString addpath_txt = tr ("&Add Directory to Load Path");
   QString cancel_txt = tr ("Cancel");
 
   QStringList btn;
--- a/libgui/src/workspace-view.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/libgui/src/workspace-view.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -243,6 +243,8 @@
 
   settings->sync ();
 
+  octave_dock_widget::save_settings ();
+
   if (m_sig_mapper)
     delete m_sig_mapper;
 }
--- a/liboctave/array/CMatrix.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/liboctave/array/CMatrix.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -709,6 +709,28 @@
   return index (idx_vector::colon, idx_vector (i));
 }
 
+// Local function to calculate the 1-norm.
+static
+double
+norm1 (const ComplexMatrix& a)
+{
+  ColumnVector colsum = a.abs ().sum ().row (0);
+  double anorm = -octave::numeric_limits<double>::Inf ();
+
+  for (octave_idx_type i = 0; i < colsum.numel (); i++)
+    {
+      if (octave::math::isnan (colsum.xelem (i)))
+        {
+          anorm = octave::numeric_limits<double>::NaN ();
+          break;
+        }
+      else
+        anorm = std::max (anorm, colsum.xelem (i));
+    }
+
+  return anorm;
+}
+
 ComplexMatrix
 ComplexMatrix::inverse (void) const
 {
@@ -847,9 +869,8 @@
   info = 0;
   tmp_info = 0;
 
-  // Calculate (always, see bug #45577) the norm of the matrix, for later use.
-  double anorm =
-    retval.abs ().sum ().row (static_cast<octave_idx_type>(0)).max ();
+  // Calculate norm of the matrix (always, see bug #45577) for later use.
+  double anorm = norm1 (retval);
 
   // Work around bug #45577, LAPACK crashes Octave if norm is NaN
   // and bug #46330, segfault with matrices containing Inf & NaN
@@ -1375,7 +1396,8 @@
       Complex *tmp_data = atmp.fortran_vec ();
 
       double anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1428,8 +1450,8 @@
 
       info = 0;
 
-      // Calculate (always, see bug #45577) the norm of the matrix, for later use.
-      double anorm = xnorm (*this, 1);
+      // Calculate norm of the matrix (always, see bug #45577) for later use.
+      double anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1584,8 +1606,7 @@
               ComplexMatrix atmp = *this;
               Complex *tmp_data = atmp.fortran_vec ();
 
-              anorm = atmp.abs().sum().
-                      row(static_cast<octave_idx_type>(0)).max();
+              anorm = norm1 (atmp);
 
               F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          F77_DBLE_CMPLX_ARG (tmp_data), nr, info
@@ -1626,8 +1647,7 @@
               F77_INT *pipvt = ipvt.fortran_vec ();
 
               if (anorm < 0.)
-                anorm = atmp.abs ().sum ().
-                        row(static_cast<octave_idx_type>(0)).max ();
+                anorm = norm1 (atmp);
 
               Array<Complex> z (dim_vector (2 * nc, 1));
               Complex *pz = z.fortran_vec ();
@@ -1897,7 +1917,7 @@
           ComplexMatrix atmp = *this;
           Complex *tmp_data = atmp.fortran_vec ();
 
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -1985,8 +2005,7 @@
 
           // Calculate the norm of the matrix, for later use.
           if (anorm < 0.)
-            anorm = atmp.abs ().sum ().row (static_cast<octave_idx_type>(0))
-                    .max ();
+            anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -2553,7 +2572,7 @@
       lwork = static_cast<F77_INT> (std::real (work(0)));
       work.resize (dim_vector (lwork, 1));
 
-      anorm = xnorm (*this, 1);
+      anorm = norm1 (*this);
 
       if (octave::math::isinf (anorm) || octave::math::isnan (anorm))
         {
--- a/liboctave/array/dMatrix.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/liboctave/array/dMatrix.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -423,6 +423,28 @@
   return index (idx_vector::colon, idx_vector (i));
 }
 
+// Local function to calculate the 1-norm.
+static
+double
+norm1 (const Matrix& a)
+{
+  ColumnVector colsum = a.abs ().sum ().row (0);
+  double anorm = -octave::numeric_limits<double>::Inf ();
+
+  for (octave_idx_type i = 0; i < colsum.numel (); i++)
+    {
+      if (octave::math::isnan (colsum.xelem (i)))
+        {
+          anorm = octave::numeric_limits<double>::NaN ();
+          break;
+        }
+      else
+        anorm = std::max (anorm, colsum.xelem (i));
+    }
+
+  return anorm;
+}
+
 Matrix
 Matrix::inverse (void) const
 {
@@ -562,8 +584,7 @@
   // Calculate the norm of the matrix, for later use.
   double anorm = 0;
   if (calc_cond)
-    anorm = retval.abs ().sum ().row (static_cast<octave_idx_type>(0))
-            .max ();
+    anorm = norm1 (retval);
 
   F77_XFCN (dgetrf, DGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
 
@@ -1048,9 +1069,8 @@
 
   volatile int typ = mattype.type ();
 
-  // Even though the matrix is marked as singular (Rectangular), we may
-  // still get a useful number from the LU factorization, because it always
-  // completes.
+  // Even though the matrix is marked as singular (Rectangular), we may still
+  // get a useful number from the LU factorization, because it always completes.
 
   if (typ == MatrixType::Unknown)
     typ = mattype.type (*this);
@@ -1068,7 +1088,8 @@
       double *tmp_data = atmp.fortran_vec ();
 
       double anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1124,7 +1145,8 @@
 
       // Calculate the norm of the matrix, for later use.
       double anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
 
@@ -1270,8 +1292,7 @@
               Matrix atmp = *this;
               double *tmp_data = atmp.fortran_vec ();
 
-              anorm = atmp.abs().sum().
-                      row(static_cast<octave_idx_type>(0)).max();
+              anorm = norm1 (atmp);
 
               F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1311,8 +1332,7 @@
               F77_INT *pipvt = ipvt.fortran_vec ();
 
               if (anorm < 0.)
-                anorm = atmp.abs ().sum ().
-                        row(static_cast<octave_idx_type>(0)).max ();
+                anorm = norm1 (atmp);
 
               Array<double> z (dim_vector (4 * nc, 1));
               double *pz = z.fortran_vec ();
@@ -1571,7 +1591,7 @@
           Matrix atmp = *this;
           double *tmp_data = atmp.fortran_vec ();
 
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -1656,7 +1676,7 @@
           double *tmp_data = atmp.fortran_vec ();
 
           if (anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+            anorm = norm1 (atmp);
 
           Array<double> z (dim_vector (4 * nc, 1));
           double *pz = z.fortran_vec ();
@@ -2204,7 +2224,7 @@
       lwork = static_cast<F77_INT> (work(0));
       work.resize (dim_vector (lwork, 1));
 
-      anorm = xnorm (*this, 1);
+      anorm = norm1 (*this);
 
       if (octave::math::isinf (anorm) || octave::math::isnan (anorm))
         {
--- a/liboctave/array/fCMatrix.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/liboctave/array/fCMatrix.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -712,6 +712,28 @@
   return index (idx_vector::colon, idx_vector (i));
 }
 
+// Local function to calculate the 1-norm.
+static
+float
+norm1 (const FloatComplexMatrix& a)
+{
+  FloatColumnVector colsum = a.abs ().sum ().row (0);
+  float anorm = -octave::numeric_limits<float>::Inf ();
+
+  for (octave_idx_type i = 0; i < colsum.numel (); i++)
+    {
+      if (octave::math::isnan (colsum.xelem (i)))
+        {
+          anorm = octave::numeric_limits<float>::NaN ();
+          break;
+        }
+      else
+        anorm = std::max (anorm, colsum.xelem (i));
+    }
+
+  return anorm;
+}
+
 FloatComplexMatrix
 FloatComplexMatrix::inverse (void) const
 {
@@ -850,9 +872,8 @@
   info = 0;
   tmp_info = 0;
 
-  // Calculate (always, see bug #45577) the norm of the matrix, for later use.
-  float anorm =
-    retval.abs ().sum ().row (static_cast<octave_idx_type>(0)).max ();
+  // Calculate norm of the matrix (always, see bug #45577) for later use.
+  float anorm = norm1 (retval);
 
   // Work around bug #45577, LAPACK crashes Octave if norm is NaN
   // and bug #46330, segfault with matrices containing Inf & NaN
@@ -1375,7 +1396,8 @@
       FloatComplex *tmp_data = atmp.fortran_vec ();
 
       float anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1428,8 +1450,8 @@
 
       info = 0;
 
-      // Calculate (always, see bug #45577) the norm of the matrix, for later use.
-      float anorm = xnorm (*this, 1);
+      // Calculate norm of the matrix (always, see bug #45577) for later use.
+      float anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1583,8 +1605,7 @@
               FloatComplexMatrix atmp = *this;
               FloatComplex *tmp_data = atmp.fortran_vec ();
 
-              anorm = atmp.abs().sum().
-                      row(static_cast<octave_idx_type>(0)).max();
+              anorm = norm1 (atmp);
 
               F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          F77_CMPLX_ARG (tmp_data), nr, info
@@ -1625,8 +1646,7 @@
               F77_INT *pipvt = ipvt.fortran_vec ();
 
               if (anorm < 0.)
-                anorm = atmp.abs ().sum ().
-                        row(static_cast<octave_idx_type>(0)).max ();
+                anorm = norm1 (atmp);
 
               Array<FloatComplex> z (dim_vector (2 * nc, 1));
               FloatComplex *pz = z.fortran_vec ();
@@ -1903,7 +1923,7 @@
           FloatComplexMatrix atmp = *this;
           FloatComplex *tmp_data = atmp.fortran_vec ();
 
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -1991,8 +2011,7 @@
 
           // Calculate the norm of the matrix, for later use.
           if (anorm < 0.)
-            anorm = atmp.abs ().sum ().row (static_cast<octave_idx_type>(0))
-                    .max ();
+            anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -2574,7 +2593,7 @@
       lwork = static_cast<F77_INT> (std::real (work(0)));
       work.resize (dim_vector (lwork, 1));
 
-      anorm = xnorm (*this, 1);
+      anorm = norm1 (*this);
 
       if (octave::math::isinf (anorm) || octave::math::isnan (anorm))
         {
--- a/liboctave/array/fMatrix.cc	Thu Nov 23 10:45:19 2017 -0800
+++ b/liboctave/array/fMatrix.cc	Thu Nov 23 13:57:42 2017 -0800
@@ -429,6 +429,28 @@
   return index (idx_vector::colon, idx_vector (i));
 }
 
+// Local function to calculate the 1-norm.
+static
+float
+norm1 (const FloatMatrix& a)
+{
+  FloatColumnVector colsum = a.abs ().sum ().row (0);
+  float anorm = -octave::numeric_limits<float>::Inf ();
+
+  for (octave_idx_type i = 0; i < colsum.numel (); i++)
+    {
+      if (octave::math::isnan (colsum.xelem (i)))
+        {
+          anorm = octave::numeric_limits<float>::NaN ();
+          break;
+        }
+      else
+        anorm = std::max (anorm, colsum.xelem (i));
+    }
+
+  return anorm;
+}
+
 FloatMatrix
 FloatMatrix::inverse (void) const
 {
@@ -568,8 +590,7 @@
   // Calculate the norm of the matrix, for later use.
   float anorm = 0;
   if (calc_cond)
-    anorm = retval.abs ().sum ().row (static_cast<octave_idx_type>(0))
-            .max ();
+    anorm = norm1 (retval);
 
   F77_XFCN (sgetrf, SGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
 
@@ -1074,7 +1095,8 @@
       float *tmp_data = atmp.fortran_vec ();
 
       float anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_INT tmp_info = 0;
 
@@ -1130,7 +1152,8 @@
 
       // Calculate the norm of the matrix, for later use.
       float anorm = 0;
-      if (calc_cond) anorm = xnorm (*this, 1);
+      if (calc_cond)
+        anorm = norm1 (*this);
 
       F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
 
@@ -1276,8 +1299,7 @@
               FloatMatrix atmp = *this;
               float *tmp_data = atmp.fortran_vec ();
 
-              anorm = atmp.abs().sum().
-                      row(static_cast<octave_idx_type>(0)).max();
+              anorm = norm1 (atmp);
 
               F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1317,8 +1339,7 @@
               F77_INT *pipvt = ipvt.fortran_vec ();
 
               if (anorm < 0.)
-                anorm = atmp.abs ().sum ().
-                        row(static_cast<octave_idx_type>(0)).max ();
+                anorm = norm1 (atmp);
 
               Array<float> z (dim_vector (4 * nc, 1));
               float *pz = z.fortran_vec ();
@@ -1592,7 +1613,7 @@
           FloatMatrix atmp = *this;
           float *tmp_data = atmp.fortran_vec ();
 
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = norm1 (atmp);
 
           F77_INT tmp_info = 0;
 
@@ -1673,8 +1694,8 @@
           FloatMatrix atmp = *this;
           float *tmp_data = atmp.fortran_vec ();
 
-          if (anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          if (anorm < 0.0)
+            anorm = norm1 (atmp);
 
           Array<float> z (dim_vector (4 * nc, 1));
           float *pz = z.fortran_vec ();
@@ -2098,6 +2119,7 @@
   return lssolve (b, info, rank, rcon);
 }
 
+
 FloatMatrix
 FloatMatrix::lssolve (const FloatMatrix& b, octave_idx_type& info,
                       octave_idx_type& rank, float& rcon) const
@@ -2227,7 +2249,7 @@
       lwork = static_cast<F77_INT> (work(0));
       work.resize (dim_vector (lwork, 1));
 
-      anorm = xnorm (*this, 1);
+      anorm = norm1 (*this);
 
       if (octave::math::isinf (anorm) || octave::math::isnan (anorm))
         {