diff src/DLD-FUNCTIONS/det.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 eb7bdde776f2
children 87865ed7405f
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/det.cc	Wed May 14 18:09:56 2008 +0200
+++ b/src/DLD-FUNCTIONS/det.cc	Sun Apr 27 22:34:17 2008 +0200
@@ -27,6 +27,8 @@
 
 #include "CmplxDET.h"
 #include "dbleDET.h"
+#include "fCmplxDET.h"
+#include "floatDET.h"
 
 #include "defun-dld.h"
 #include "error.h"
@@ -75,74 +77,114 @@
       return retval;
     }
 
-  if (arg.is_real_type ())
+
+  if (arg.is_single_type ())
     {
-      octave_idx_type info;
-      double rcond = 0.0;
-      // Always compute rcond, so we can detect numerically
-      // singular matrices.
-      if (arg.is_sparse_type ())
+      if (arg.is_real_type ())
 	{
-	  SparseMatrix m = arg.sparse_matrix_value ();
+	  octave_idx_type info;
+	  float rcond = 0.0;
+	  // Always compute rcond, so we can detect numerically
+	  // singular matrices.
+	  FloatMatrix m = arg.float_matrix_value ();
 	  if (! error_state)
 	    {
-	      DET det = m.determinant (info, rcond);
+	      FloatDET det = m.determinant (info, rcond);
 	      retval(1) = rcond;
-	      volatile double xrcond = rcond;
-	      xrcond += 1.0;
-	      retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
-	    }
-	}
-      else
-	{
-	  Matrix m = arg.matrix_value ();
-	  if (! error_state)
-	    {
-	      DET det = m.determinant (info, rcond);
-	      retval(1) = rcond;
-	      volatile double xrcond = rcond;
+	      volatile float xrcond = rcond;
 	      xrcond += 1.0;
 	      retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
 	    }
 	}
-    }
-  else if (arg.is_complex_type ())
-    {
-      octave_idx_type info;
-      double rcond = 0.0;
-      // Always compute rcond, so we can detect numerically
-      // singular matrices.
-      if (arg.is_sparse_type ())
+      else if (arg.is_complex_type ())
 	{
-	  SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
+	  octave_idx_type info;
+	  float rcond = 0.0;
+	  // Always compute rcond, so we can detect numerically
+	  // singular matrices.
+	  FloatComplexMatrix m = arg.float_complex_matrix_value ();
 	  if (! error_state)
 	    {
-	      ComplexDET det = m.determinant (info, rcond);
+	      FloatComplexDET det = m.determinant (info, rcond);
 	      retval(1) = rcond;
-	      volatile double xrcond = rcond;
+	      volatile float xrcond = rcond;
 	      xrcond += 1.0;
 	      retval(0) = ((info == -1 || xrcond == 1.0) 
 			   ? Complex (0.0) : det.value ());
-	    }
-	}
-      else
-	{
-	  ComplexMatrix m = arg.complex_matrix_value ();
-	  if (! error_state)
-	    {
-	      ComplexDET det = m.determinant (info, rcond);
-	      retval(1) = rcond;
-	      volatile double xrcond = rcond;
-	      xrcond += 1.0;
-	      retval(0) = ((info == -1 || xrcond == 1.0) 
-			   ? Complex (0.0) : det.value ());
-
+	      
 	    }
 	}
     }
   else
-    gripe_wrong_type_arg ("det", arg);
+    {
+      if (arg.is_real_type ())
+	{
+	  octave_idx_type info;
+	  double rcond = 0.0;
+	  // Always compute rcond, so we can detect numerically
+	  // singular matrices.
+	  if (arg.is_sparse_type ())
+	    {
+	      SparseMatrix m = arg.sparse_matrix_value ();
+	      if (! error_state)
+		{
+		  DET det = m.determinant (info, rcond);
+		  retval(1) = rcond;
+		  volatile double xrcond = rcond;
+		  xrcond += 1.0;
+		  retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
+		}
+	    }
+	  else
+	    {
+	      Matrix m = arg.matrix_value ();
+	      if (! error_state)
+		{
+		  DET det = m.determinant (info, rcond);
+		  retval(1) = rcond;
+		  volatile double xrcond = rcond;
+		  xrcond += 1.0;
+		  retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
+		}
+	    }
+	}
+      else if (arg.is_complex_type ())
+	{
+	  octave_idx_type info;
+	  double rcond = 0.0;
+	  // Always compute rcond, so we can detect numerically
+	  // singular matrices.
+	  if (arg.is_sparse_type ())
+	    {
+	      SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
+	      if (! error_state)
+		{
+		  ComplexDET det = m.determinant (info, rcond);
+		  retval(1) = rcond;
+		  volatile double xrcond = rcond;
+		  xrcond += 1.0;
+		  retval(0) = ((info == -1 || xrcond == 1.0) 
+			       ? Complex (0.0) : det.value ());
+		}
+	    }
+	  else
+	    {
+	      ComplexMatrix m = arg.complex_matrix_value ();
+	      if (! error_state)
+		{
+		  ComplexDET det = m.determinant (info, rcond);
+		  retval(1) = rcond;
+		  volatile double xrcond = rcond;
+		  xrcond += 1.0;
+		  retval(0) = ((info == -1 || xrcond == 1.0) 
+			       ? Complex (0.0) : det.value ());
 
+		}
+	    }
+	}
+      else
+	gripe_wrong_type_arg ("det", arg);
+    }
   return retval;
 }