diff libinterp/corefcn/xpow.cc @ 20679:19d6f94c21cb

eliminate more uses of error_state * graphics.cc, ls-mat5.cc, urlwrite.cc, xpow.cc, ov-class.cc: Eliminate some uses of error_state.
author John W. Eaton <jwe@octave.org>
date Thu, 05 Nov 2015 15:06:52 -0500
parents a9574e3c6e9e
children 48b2ad5ee801
line wrap: on
line diff
--- a/libinterp/corefcn/xpow.cc	Wed Nov 04 15:56:22 2015 -0500
+++ b/libinterp/corefcn/xpow.cc	Thu Nov 05 15:06:52 2015 -0500
@@ -54,6 +54,12 @@
 
 #include "bsxfun.h"
 
+static void
+gripe_failed_diagonalization (void)
+{
+  gripe_failed_diagonalization ();
+}
+
 static inline int
 xisint (double x)
 {
@@ -106,10 +112,10 @@
     error ("for x^A, A must be a square matrix. Use .^ for elementwise power.");
   else
     {
-      EIG b_eig (b);
-
-      if (! error_state)
+      try
         {
+          EIG b_eig (b);
+
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
 
@@ -129,8 +135,10 @@
           else
             retval = C;
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -159,7 +167,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -176,8 +184,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -248,7 +258,7 @@
         {
           EIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               ComplexColumnVector lambda (a_eig.eigenvalues ());
               ComplexMatrix Q (a_eig.eigenvectors ());
@@ -260,8 +270,10 @@
 
               retval = ComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -327,7 +339,7 @@
     {
       EIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (a_eig.eigenvalues ());
           ComplexMatrix Q (a_eig.eigenvectors ());
@@ -339,8 +351,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -375,7 +389,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -392,8 +406,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -423,7 +439,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -440,8 +456,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -512,7 +530,7 @@
         {
           EIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               ComplexColumnVector lambda (a_eig.eigenvalues ());
               ComplexMatrix Q (a_eig.eigenvectors ());
@@ -524,8 +542,10 @@
 
               retval = ComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -547,7 +567,7 @@
     {
       EIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (a_eig.eigenvalues ());
           ComplexMatrix Q (a_eig.eigenvectors ());
@@ -559,8 +579,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1553,7 +1575,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1575,8 +1597,10 @@
           else
             retval = C;
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1605,7 +1629,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1622,8 +1646,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1694,7 +1720,7 @@
         {
           FloatEIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               FloatComplexColumnVector lambda (a_eig.eigenvalues ());
               FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1706,8 +1732,10 @@
 
               retval = FloatComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -1762,7 +1790,7 @@
     {
       FloatEIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (a_eig.eigenvalues ());
           FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1774,8 +1802,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1810,7 +1840,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1827,8 +1857,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1858,7 +1890,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1875,8 +1907,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1947,7 +1981,7 @@
         {
           FloatEIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               FloatComplexColumnVector lambda (a_eig.eigenvalues ());
               FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1959,8 +1993,10 @@
 
               retval = FloatComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -1982,7 +2018,7 @@
     {
       FloatEIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (a_eig.eigenvalues ());
           FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1994,8 +2030,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;