diff src/DLD-FUNCTIONS/qr.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 efccca5f2ad7
children 87865ed7405f
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/qr.cc
+++ b/src/DLD-FUNCTIONS/qr.cc
@@ -32,6 +32,10 @@
 #include "CmplxQRP.h"
 #include "dbleQR.h"
 #include "dbleQRP.h"
+#include "fCmplxQR.h"
+#include "fCmplxQRP.h"
+#include "floatQR.h"
+#include "floatQRP.h"
 #include "SparseQR.h"
 #include "SparseCmplxQR.h"
 
@@ -275,78 +279,154 @@
       QR::type type = (nargout == 0 || nargout == 1) ? QR::raw
 	: (nargin == 2 ? QR::economy : QR::std);
 
-      if (arg.is_real_type ())
+      if (arg.is_single_type ())
 	{
-	  Matrix m = arg.matrix_value ();
+	  if (arg.is_real_type ())
+	    {
+	      FloatMatrix m = arg.float_matrix_value ();
 
-	  if (! error_state)
-	    {
-	      switch (nargout)
+	      if (! error_state)
 		{
-		case 0:
-		case 1:
-		  {
-		    QR fact (m, type);
-		    retval(0) = fact.R ();
-		  }
-		  break;
+		  switch (nargout)
+		    {
+		    case 0:
+		    case 1:
+		      {
+			FloatQR fact (m, type);
+			retval(0) = fact.R ();
+		      }
+		      break;
 
-		case 2:
-		  {
-		    QR fact (m, type);
-		    retval(1) = fact.R ();
-		    retval(0) = fact.Q ();
-		  }
-		  break;
+		    case 2:
+		      {
+			FloatQR fact (m, type);
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
 
-		default:
-		  {
-		    QRP fact (m, type);
-		    retval(2) = fact.P ();
-		    retval(1) = fact.R ();
-		    retval(0) = fact.Q ();
-		  }
-		  break;
+		    default:
+		      {
+			FloatQRP fact (m, type);
+			retval(2) = fact.P ();
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+		    }
 		}
 	    }
-	}
-      else if (arg.is_complex_type ())
-	{
-	  ComplexMatrix m = arg.complex_matrix_value ();
-
-	  if (! error_state)
+	  else if (arg.is_complex_type ())
 	    {
-	      switch (nargout)
+	      FloatComplexMatrix m = arg.float_complex_matrix_value ();
+
+	      if (! error_state)
 		{
-		case 0:
-		case 1:
-		  {
-		    ComplexQR fact (m, type);
-		    retval(0) = fact.R ();
-		  }
-		  break;
+		  switch (nargout)
+		    {
+		    case 0:
+		    case 1:
+		      {
+			FloatComplexQR fact (m, type);
+			retval(0) = fact.R ();
+		      }
+		      break;
 
-		case 2:
-		  {
-		    ComplexQR fact (m, type);
-		    retval(1) = fact.R ();
-		    retval(0) = fact.Q ();
-		  }
-		  break;
+		    case 2:
+		      {
+			FloatComplexQR fact (m, type);
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
 
-		default:
-		  {
-		    ComplexQRP fact (m, type);
-		    retval(2) = fact.P ();
-		    retval(1) = fact.R ();
-		    retval(0) = fact.Q ();
-		  }
-		  break;
+		    default:
+		      {
+			FloatComplexQRP fact (m, type);
+			retval(2) = fact.P ();
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+		    }
 		}
 	    }
 	}
       else
-	gripe_wrong_type_arg ("qr", arg);
+	{
+	  if (arg.is_real_type ())
+	    {
+	      Matrix m = arg.matrix_value ();
+
+	      if (! error_state)
+		{
+		  switch (nargout)
+		    {
+		    case 0:
+		    case 1:
+		      {
+			QR fact (m, type);
+			retval(0) = fact.R ();
+		      }
+		      break;
+
+		    case 2:
+		      {
+			QR fact (m, type);
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+
+		    default:
+		      {
+			QRP fact (m, type);
+			retval(2) = fact.P ();
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+		    }
+		}
+	    }
+	  else if (arg.is_complex_type ())
+	    {
+	      ComplexMatrix m = arg.complex_matrix_value ();
+
+	      if (! error_state)
+		{
+		  switch (nargout)
+		    {
+		    case 0:
+		    case 1:
+		      {
+			ComplexQR fact (m, type);
+			retval(0) = fact.R ();
+		      }
+		      break;
+
+		    case 2:
+		      {
+			ComplexQR fact (m, type);
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+
+		    default:
+		      {
+			ComplexQRP fact (m, type);
+			retval(2) = fact.P ();
+			retval(1) = fact.R ();
+			retval(0) = fact.Q ();
+		      }
+		      break;
+		    }
+		}
+	    }
+	  else
+	    gripe_wrong_type_arg ("qr", arg);
+	}
     }
 
   return retval;