diff src/DLD-FUNCTIONS/gammainc.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 a1dbe9d80eee
children a41df65f3f00
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/gammainc.cc	Wed May 14 18:09:56 2008 +0200
+++ b/src/DLD-FUNCTIONS/gammainc.cc	Sun Apr 27 22:34:17 2008 +0200
@@ -74,47 +74,98 @@
       octave_value x_arg = args(0);
       octave_value a_arg = args(1);
 
-      if (x_arg.is_scalar_type ())
+      // FIXME Can we make a template version of the duplicated code below
+      if (x_arg.is_single_type () || a_arg.is_single_type ())
 	{
-	  double x = x_arg.double_value ();
+	  if (x_arg.is_scalar_type ())
+	    {
+	      float x = x_arg.float_value ();
 
-	  if (! error_state)
-	    {
-	      if (a_arg.is_scalar_type ())
+	      if (! error_state)
 		{
-		  double a = a_arg.double_value ();
+		  if (a_arg.is_scalar_type ())
+		    {
+		      float a = a_arg.float_value ();
+
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
+		  else
+		    {
+		      FloatNDArray a = a_arg.float_array_value ();
 
-		  if (! error_state)
-		    retval = gammainc (x, a);
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
 		}
-	      else
+	    }
+	  else
+	    {
+	      FloatNDArray x = x_arg.float_array_value ();
+
+	      if (! error_state)
 		{
-		  NDArray a = a_arg.array_value ();
+		  if (a_arg.is_scalar_type ())
+		    {
+		      float a = a_arg.float_value ();
 
-		  if (! error_state)
-		    retval = gammainc (x, a);
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
+		  else
+		    {
+		      FloatNDArray a = a_arg.float_array_value ();
+
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
 		}
 	    }
 	}
       else
 	{
-	  NDArray x = x_arg.array_value ();
-
-	  if (! error_state)
+	  if (x_arg.is_scalar_type ())
 	    {
-	      if (a_arg.is_scalar_type ())
+	      double x = x_arg.double_value ();
+
+	      if (! error_state)
 		{
-		  double a = a_arg.double_value ();
+		  if (a_arg.is_scalar_type ())
+		    {
+		      double a = a_arg.double_value ();
+
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
+		  else
+		    {
+		      NDArray a = a_arg.array_value ();
 
-		  if (! error_state)
-		    retval = gammainc (x, a);
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
 		}
-	      else
+	    }
+	  else
+	    {
+	      NDArray x = x_arg.array_value ();
+
+	      if (! error_state)
 		{
-		  NDArray a = a_arg.array_value ();
+		  if (a_arg.is_scalar_type ())
+		    {
+		      double a = a_arg.double_value ();
 
-		  if (! error_state)
-		    retval = gammainc (x, a);
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
+		  else
+		    {
+		      NDArray a = a_arg.array_value ();
+
+		      if (! error_state)
+			retval = gammainc (x, a);
+		    }
 		}
 	    }
 	}