diff src/xpow.cc @ 3162:7c96e85c76db

[project @ 1998-04-08 18:19:35 by jwe]
author jwe
date Wed, 08 Apr 1998 18:21:04 +0000
parents dcc6c985d72d
children 09a3064a3a17
line wrap: on
line diff
--- a/src/xpow.cc	Mon Mar 02 06:27:23 1998 +0000
+++ b/src/xpow.cc	Wed Apr 08 18:21:04 1998 +0000
@@ -446,6 +446,20 @@
 //
 //   * -> not needed.
 
+// XXX FIXME XXX -- these functions need to be fixed so that things
+// like
+//
+//   a = -1; b = [ 0, 0.5, 1 ]; r = a .^ b
+//
+// and
+//
+//   a = -1; b = [ 0, 0.5, 1 ]; for i = 1:3, r(i) = a .^ b(i), end
+//
+// produce identical results.  Also, it would be nice if -1^0.5
+// produced a pure imaginary result instead of a complex number with a
+// small real part.  But perhaps that's really a problem with the math
+// library...
+
 // -*- 1 -*-
 octave_value
 elem_xpow (double a, const Matrix& b)
@@ -455,9 +469,9 @@
   int nr = b.rows ();
   int nc = b.cols ();
 
-  // For now, assume the worst.
+  double d1, d2;
 
-  if (a < 0.0)
+  if (a < 0.0 && ! b.all_integers (d1, d2))
     {
       Complex atmp (a);
       ComplexMatrix result (nr, nc);