diff src/DLD-FUNCTIONS/eig.cc @ 7789:82be108cc558

First attempt at single precision tyeps * * * corrections to qrupdate single precision routines * * * prefer demotion to single over promotion to double * * * Add single precision support to log2 function * * * Trivial PROJECT file update * * * Cache optimized hermitian/transpose methods * * * Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author David Bateman <dbateman@free.fr>
date Sun, 27 Apr 2008 22:34:17 +0200
parents 91f8446ce4ae
children 87865ed7405f
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/eig.cc	Wed May 14 18:09:56 2008 +0200
+++ b/src/DLD-FUNCTIONS/eig.cc	Sun Apr 27 22:34:17 2008 +0200
@@ -26,6 +26,7 @@
 #endif
 
 #include "EIG.h"
+#include "fEIG.h"
 
 #include "defun-dld.h"
 #include "error.h"
@@ -75,46 +76,92 @@
 
   Matrix tmp;
   ComplexMatrix ctmp;
-  EIG result;
+  FloatMatrix ftmp;
+  FloatComplexMatrix fctmp;
+
+  if (arg.is_single_type ())
+    {
+      FloatEIG result;
 
-  if (arg.is_real_type ())
-    {
-      tmp = arg.matrix_value ();
+      if (arg.is_real_type ())
+	{
+	  ftmp = arg.float_matrix_value ();
+
+	  if (error_state)
+	    return retval;
+	  else
+	    result = FloatEIG (ftmp, nargout > 1);
+	}
+      else if (arg.is_complex_type ())
+	{
+	  fctmp = arg.float_complex_matrix_value ();
 
-      if (error_state)
-	return retval;
-      else
-	result = EIG (tmp, nargout > 1);
-    }
-  else if (arg.is_complex_type ())
-    {
-      ctmp = arg.complex_matrix_value ();
+	  if (error_state)
+	    return retval;
+	  else
+	    result = FloatEIG (fctmp, nargout > 1);
+	}
 
-      if (error_state)
-	return retval;
-      else
-	result = EIG (ctmp, nargout > 1);
+      if (! error_state)
+	{
+	  if (nargout == 0 || nargout == 1)
+	    {
+	      retval(0) = result.eigenvalues ();
+	    }
+	  else
+	    {
+	      // Blame it on Matlab.
+
+	      FloatComplexDiagMatrix d (result.eigenvalues ());
+
+	      retval(1) = d;
+	      retval(0) = result.eigenvectors ();
+	    }
+	}
     }
   else
     {
-      gripe_wrong_type_arg ("eig", tmp);
-      return retval;
-    }
+      EIG result;
+
+      if (arg.is_real_type ())
+	{
+	  tmp = arg.matrix_value ();
 
-  if (! error_state)
-    {
-      if (nargout == 0 || nargout == 1)
+	  if (error_state)
+	    return retval;
+	  else
+	    result = EIG (tmp, nargout > 1);
+	}
+      else if (arg.is_complex_type ())
 	{
-	  retval(0) = result.eigenvalues ();
+	  ctmp = arg.complex_matrix_value ();
+
+	  if (error_state)
+	    return retval;
+	  else
+	    result = EIG (ctmp, nargout > 1);
 	}
       else
 	{
-	  // Blame it on Matlab.
+	  gripe_wrong_type_arg ("eig", tmp);
+	  return retval;
+	}
 
-	  ComplexDiagMatrix d (result.eigenvalues ());
+      if (! error_state)
+	{
+	  if (nargout == 0 || nargout == 1)
+	    {
+	      retval(0) = result.eigenvalues ();
+	    }
+	  else
+	    {
+	      // Blame it on Matlab.
 
-	  retval(1) = d;
-	  retval(0) = result.eigenvectors ();
+	      ComplexDiagMatrix d (result.eigenvalues ());
+
+	      retval(1) = d;
+	      retval(0) = result.eigenvectors ();
+	    }
 	}
     }