diff src/xpow.cc @ 11030:231946a9ad55

make the result of r^m real when r > 0
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 28 Sep 2010 13:56:10 +0200
parents a046d03e2417
children fd0a3ac60b0e
line wrap: on
line diff
--- a/src/xpow.cc	Tue Sep 28 09:08:29 2010 +0200
+++ b/src/xpow.cc	Tue Sep 28 13:56:10 2010 +0200
@@ -123,7 +123,11 @@
             }
           ComplexDiagMatrix D (lambda);
 
-          retval = ComplexMatrix (Q * D * Q.inverse ());
+          ComplexMatrix C = Q * D * Q.inverse ();
+          if (a > 0)
+            retval = real (C);
+          else
+            retval = C;
         }
       else
         error ("xpow: matrix diagonalization failed");
@@ -1534,7 +1538,12 @@
             }
           FloatComplexDiagMatrix D (lambda);
 
-          retval = FloatComplexMatrix (Q * D * Q.inverse ());
+          FloatComplexMatrix C = Q * D * Q.inverse ();
+
+          if (a > 0)
+            retval = real (C);
+          else
+            retval = C;
         }
       else
         error ("xpow: matrix diagonalization failed");