changeset 24229:97e628756971

Adjust coding code in cset 1310d8b50ec2 for Octave coding conventions. * eigs-base.cc, eigs.m: Adjust coding code in cset 1310d8b50ec2 for Octave coding conventions.
author Rik <rik@octave.org>
date Mon, 13 Nov 2017 20:48:06 -0800
parents 1310d8b50ec2
children 0350da83c049
files liboctave/numeric/eigs-base.cc scripts/sparse/eigs.m
diffstat 2 files changed, 65 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/numeric/eigs-base.cc	Fri Mar 24 14:41:08 2017 +0100
+++ b/liboctave/numeric/eigs-base.cc	Mon Nov 13 20:48:06 2017 -0800
@@ -282,7 +282,7 @@
         {
           if (permB.numel ())
             {
-              SparseMatrix tmp(n,n,n);
+              SparseMatrix tmp (n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
                 {
                   tmp.xcidx (i) = i;
@@ -446,7 +446,7 @@
         {
           if (permB.numel ())
             {
-              SparseMatrix tmp(n,n,n);
+              SparseMatrix tmp (n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
                 {
                   tmp.xcidx (i) = i;
@@ -627,9 +627,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -653,7 +651,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -912,9 +910,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -938,7 +934,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -1044,7 +1040,7 @@
 
                   vector_product (b, workd+iptr(0)-1, dtmp);
 
-                  Matrix tmp(n, 1);
+                  Matrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = dtmp[P[i]];
@@ -1060,7 +1056,7 @@
               else
                 {
                   double *ip2 = workd+iptr(2)-1;
-                  Matrix tmp(n, 1);
+                  Matrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = ip2[P[i]];
@@ -1074,10 +1070,9 @@
             }
           else
             {
-              // ido cannot be 2 for non-generalized problems
-              // see dsaupd2
+              // ido cannot be 2 for non-generalized problems (see dsaupd2).
               double *ip2 = workd+iptr(0)-1;
-              Matrix tmp(n, 1);
+              Matrix tmp (n, 1);
 
               for (F77_INT i = 0; i < n; i++)
                 tmp(i,0) = ip2[P[i]];
@@ -1194,9 +1189,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (n != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -1220,7 +1213,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (! have_sigma)
     {
@@ -1451,9 +1444,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -1477,7 +1468,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -1560,15 +1551,15 @@
     {
       F77_INT tmp_info = octave::to_f77_int (info);
 
-      // on exit, ip(4) <= k + 1 is the number of converged eigenvalues
-      // see dnaupd2
+      // On exit, ip(4) <= k + 1 is the number of converged eigenvalues.
+      // See dnaupd2.
       F77_FUNC (dnaupd, DNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
          F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, tmp_info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
-       // k is not changed
+      // k is not changed
 
       info = tmp_info;
 
@@ -1652,7 +1643,7 @@
   for (F77_INT i = 0; i < k+1; i++)
     dr[i] = di[i] = 0.;
 
-  F77_INT k0 = k; // original number of eigenvalues required
+  F77_INT k0 = k;  // original number of eigenvalues required
   F77_FUNC (dneupd, DNEUPD)
     (rvec, F77_CONST_CHAR_ARG2 ("A", 1), sel, dr, di, z, n, sigmar,
      sigmai, workev,  F77_CONST_CHAR_ARG2 (&bmat, 1), n,
@@ -1660,7 +1651,7 @@
      ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
      F77_CHAR_ARG_LEN(2));
   // on exit, if (and only if) rvec == true, k may have been increased by one
-  // and be equal to ip(4), see dngets
+  // and be equal to ip(4), see dngets.
 
   if (f77_exception_encountered)
     (*current_liboctave_error_handler)
@@ -1773,9 +1764,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -1799,7 +1788,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -1862,8 +1851,8 @@
     {
       F77_INT tmp_info = octave::to_f77_int (info);
 
-      // on exit, ip(4) <= k + 1 is the number of converged eigenvalues
-      // see dnaupd2
+      // On exit, ip(4) <= k + 1 is the number of converged eigenvalues.
+      // See dnaupd2.
       F77_FUNC (dnaupd, DNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
          F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
@@ -1908,7 +1897,7 @@
 
                   vector_product (b, workd+iptr(0)-1, dtmp);
 
-                  Matrix tmp(n, 1);
+                  Matrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = dtmp[P[i]];
@@ -1924,7 +1913,7 @@
               else
                 {
                   double *ip2 = workd+iptr(2)-1;
-                  Matrix tmp(n, 1);
+                  Matrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = ip2[P[i]];
@@ -1938,10 +1927,9 @@
             }
           else
             {
-              // ido cannot be 2 for non-generalized problems
-              // see dnaupd2
+              // ido cannot be 2 for non-generalized problems (see dnaupd2).
               double *ip2 = workd+iptr(0)-1;
-              Matrix tmp(n, 1);
+              Matrix tmp (n, 1);
 
               for (F77_INT i = 0; i < n; i++)
                 tmp(i,0) = ip2[P[i]];
@@ -1992,15 +1980,15 @@
   for (F77_INT i = 0; i < k+1; i++)
     dr[i] = di[i] = 0.;
 
-  F77_INT k0 = k; // original number of eigenvalues required
+  F77_INT k0 = k;  // original number of eigenvalues required
   F77_FUNC (dneupd, DNEUPD)
     (rvec, F77_CONST_CHAR_ARG2 ("A", 1), sel, dr, di, z, n, sigmar,
      sigmai, workev,  F77_CONST_CHAR_ARG2 (&bmat, 1), n,
      F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v, n, iparam,
      ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
      F77_CHAR_ARG_LEN(2));
-  // on exit, if (and only if) rvec == true, k may have been increased by one
-  // and be equal to ip(4), see dngets
+  // On exit, if (and only if) rvec == true, k may have been increased by one
+  // and be equal to ip(4), see dngets.
 
   if (f77_exception_encountered)
     (*current_liboctave_error_handler)
@@ -2097,9 +2085,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (n != resid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -2123,7 +2109,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (! have_sigma)
     {
@@ -2183,15 +2169,15 @@
     {
       F77_INT tmp_info = octave::to_f77_int (info);
 
-      // on exit, ip(4) <= k + 1 is the number of converged eigenvalues
-      // see dnaupd2
+      // On exit, ip(4) <= k + 1 is the number of converged eigenvalues
+      // see dnaupd2.
       F77_FUNC (dnaupd, DNAUPD)
          (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
          F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, tmp_info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
-       // k is not changed
+      // k is not changed
 
       info = tmp_info;
 
@@ -2275,15 +2261,15 @@
   for (F77_INT i = 0; i < k+1; i++)
     dr[i] = di[i] = 0.;
 
-  F77_INT k0 = k; // original number of eigenvalues required
+  F77_INT k0 = k;  // original number of eigenvalues required
   F77_FUNC (dneupd, DNEUPD)
     (rvec, F77_CONST_CHAR_ARG2 ("A", 1), sel, dr, di, z, n, sigmar,
      sigmai, workev,  F77_CONST_CHAR_ARG2 (&bmat, 1), n,
      F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v, n, iparam,
      ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
      F77_CHAR_ARG_LEN(2));
-  // on exit, if (and only if) rvec == true, k may have been increased by one
-  // and be equal to ip(4), see dngets
+  // On exit, if (and only if) rvec == true, k may have been increased by one
+  // and be equal to ip(4), see dngets.
 
   if (f77_exception_encountered)
     (*current_liboctave_error_handler)
@@ -2393,9 +2379,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != cresid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -2419,7 +2403,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -2686,9 +2670,7 @@
       octave_rand::distribution (rand_dist);
     }
   else if (m.cols () != cresid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
     (*current_liboctave_error_handler) ("eigs: n must be at least 3");
@@ -2712,7 +2694,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (have_b && cholB && ! permB.isempty ())
     {
@@ -2820,7 +2802,7 @@
 
                   vector_product (b, workd+iptr(0)-1, ctmp);
 
-                  ComplexMatrix tmp(n, 1);
+                  ComplexMatrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = ctmp[P[i]];
@@ -2836,7 +2818,7 @@
               else
                 {
                   Complex *ip2 = workd+iptr(2)-1;
-                  ComplexMatrix tmp(n, 1);
+                  ComplexMatrix tmp (n, 1);
 
                   for (F77_INT i = 0; i < n; i++)
                     tmp(i,0) = ip2[P[i]];
@@ -2850,10 +2832,9 @@
             }
           else
             {
-              // ido cannot be 2 for non-generalized problems
-              // see znaup2
+              // ido cannot be 2 for non-generalized problems (see znaup2).
               Complex *ip2 = workd+iptr(0)-1;
-              ComplexMatrix tmp(n, 1);
+              ComplexMatrix tmp (n, 1);
 
               for (F77_INT i = 0; i < n; i++)
                 tmp(i,0) = ip2[P[i]];
@@ -2983,13 +2964,10 @@
       octave_rand::distribution (rand_dist);
     }
   else if (n != cresid.numel ())
-    {
-      (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
-    }
+    (*current_liboctave_error_handler) ("eigs: opts.v0 must be n-by-1");
 
   if (n < 3)
-    (*current_liboctave_error_handler)
-      ("eigs: n must be at least 3");
+    (*current_liboctave_error_handler) ("eigs: n must be at least 3");
 
   if (p < 0)
     {
@@ -3010,7 +2988,7 @@
 
   if (p <= k || p > n)
     (*current_liboctave_error_handler)
-      ("eigs: opts.p must be greater than k and less or equal to n");
+      ("eigs: opts.p must be greater than k and less than or equal to n");
 
   if (! have_sigma)
     {
--- a/scripts/sparse/eigs.m	Fri Mar 24 14:41:08 2017 +0100
+++ b/scripts/sparse/eigs.m	Mon Nov 13 20:48:06 2017 -0800
@@ -124,9 +124,8 @@
 ## @item p
 ## The number of Lanzcos basis vectors to use.  More vectors will result in
 ## faster convergence, but a greater use of memory.  The optimal value of
-## @code{p} is problem dependent and should be in the range
-## @code{@var{k} + 1} to @var{n}.
-## The default value is @code{2 * @var{k}}.
+## @code{p} is problem dependent and should be in the range @code{@var{k} + 1}
+## to @var{n}.  The default value is @code{2 * @var{k}}.
 ##
 ## @item v0
 ## The starting vector for the algorithm.  An initial vector close to the
@@ -1248,8 +1247,8 @@
 %! A(1, 1) = 0;
 %! A(1, 9) = 1;
 %! [V, L] = eigs (A, 4, -1);
-%! assert (!any (isnan (diag (L))))
-%! assert (any (abs (diag (L)) <= 2 * eps))
+%! assert (!any (isnan (diag (L))));
+%! assert (any (abs (diag (L)) <= 2 * eps));
 %!testif HAVE_ARPACK
 %! A = diag (ones (9, 1), 1);
 %! A(10,:) = [-1, zeros(1, 8), -1];
@@ -1257,45 +1256,45 @@
 %! typ = "lr";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (real (diag (m))), ...
-%!         [-0.081751; 0.514038; 0.514038; 0.880290; 0.880290], 1e-4)
+%!         [-0.081751; 0.514038; 0.514038; 0.880290; 0.880290], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (real (m)), ...
-%!         [-0.081751; 0.514038; 0.514038; 0.880290; 0.880290], 1e-4)
+%!         [-0.081751; 0.514038; 0.514038; 0.880290; 0.880290], 1e-4);
 %! typ = "li";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (abs (imag (diag (m)))), ...
-%!         [0.75447; 0.78972; 0.78972; 0.96518; 0.96518], 1e-4)
+%!         [0.75447; 0.78972; 0.78972; 0.96518; 0.96518], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (abs (imag (m))), ...
-%!         [0.75447; 0.78972; 0.78972; 0.96518; 0.96518], 1e-4)
+%!         [0.75447; 0.78972; 0.78972; 0.96518; 0.96518], 1e-4);
 %! typ = "sr";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (real (diag (m))), ...
-%!         [-1.12180; -1.12180; -0.69077; -0.08175; -0.08175], 1e-4)
+%!         [-1.12180; -1.12180; -0.69077; -0.08175; -0.08175], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (real (m)), ...
-%!         [-1.12180; -1.12180; -0.69077; -0.69077; -0.08175], 1e-4)
+%!         [-1.12180; -1.12180; -0.69077; -0.69077; -0.08175], 1e-4);
 %! typ = "si";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (abs (imag (diag (m)))), ...
-%!         [0.25552; 0.25552; 0.30282; 0.30282; 0.75447], 1e-4)
+%!         [0.25552; 0.25552; 0.30282; 0.30282; 0.75447], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (abs (imag (m))), ...
-%!         [0.25552; 0.25552; 0.30282; 0.30282; 0.75447], 1e-4)
+%!         [0.25552; 0.25552; 0.30282; 0.30282; 0.75447], 1e-4);
 %! typ = "lm";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (abs (diag (m))), ...
-%!         [0.96863; 0.96863;  1.02294; 1.15054; 1.15054], 1e-4)
+%!         [0.96863; 0.96863;  1.02294; 1.15054; 1.15054], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (abs (m)), ...
-%!         [0.96863; 1.02294; 1.02294; 1.15054; 1.15054], 1e-4)
+%!         [0.96863; 1.02294; 1.02294; 1.15054; 1.15054], 1e-4);
 %! typ = "sm";
 %! [v, m] = eigs (A, 5, typ, opts);
 %! assert (sort (abs (diag (m))), ...
-%!         [0.93092; 0.93092; 0.94228; 0.94228; 0.96863], 1e-4)
+%!         [0.93092; 0.93092; 0.94228; 0.94228; 0.96863], 1e-4);
 %! m = eigs (A, 5, typ, opts);
 %! assert (sort (abs (m)), ...
-%!         [0.93092; 0.93092; 0.94228; 0.94228; 0.96863], 1e-4)
+%!         [0.93092; 0.93092; 0.94228; 0.94228; 0.96863], 1e-4);
 %!testif HAVE_ARPACK
 %! A = toeplitz (sparse ([2, 1, zeros(1,8)]));
 %! opts.v0 = (1:10)';