Index: /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c
===================================================================
--- /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c	(revision 1099)
+++ /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c	(revision 1100)
@@ -29,6 +29,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-25 02:00:41 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-25 23:34:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -41,4 +41,5 @@
 #include <math.h>
 #include <stdint.h>
+#include <tgmath.h>
 
 #include "psMemory.h"
@@ -87,4 +88,18 @@
 // Conversion for radians to degrees
 #define R2D 360.0/M_PI
+
+// Division with NAN checking
+static complex double psNanDiv(complex double a, complex double b)
+{
+    complex double out = 0+0i;
+    out = a/b;
+    if(isnan(creal(out))) {
+        psError(__func__, ": NAN encountered in real portion of division");
+    } else if(isnan(cimag(out))) {
+        psError(__func__, ": NAN encountered in imaginary portion of division");
+    }
+
+    return out;
+}
 
 // Binary SCALAR_XXXX operations
@@ -362,5 +377,5 @@
     break;                                                                                                   \
 default:                                                                                                     \
-    psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, IN1->type);                               \
+    psError(__func__, ": Invalid PS_TYPE: %d", IN1->type);                                                   \
 }
 
@@ -374,5 +389,5 @@
     BINARY_TYPE(DIM1,DIM2,OUT,IN1,*i1 * *i2,IN2);                                                            \
 } else if(!strncmp(OP, "/", 1)) {                                                                            \
-    BINARY_TYPE(DIM1,DIM2,OUT,IN1,*i1 / *i2,IN2);                                                            \
+    BINARY_TYPE(DIM1,DIM2,OUT,IN1,psNanDiv(*i1,*i2),IN2);                                                    \
 } else if(!strncmp(OP, "^", 1)) {                                                                            \
     if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
@@ -382,9 +397,17 @@
     }                                                                                                        \
 } else if(!strncmp(OP, "min", 3)) {                                                                          \
-    BINARY_TYPE(DIM1,DIM2,OUT,IN1,MIN(*i1,*i2),IN2);                                                         \
+    if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
+        psError(__func__, ": Minimum operation not supported for complex numbers");                          \
+    } else {                                                                                                 \
+        BINARY_TYPE(DIM1,DIM2,OUT,IN1,fmin(*i1,*i2),IN2);                                                    \
+    }                                                                                                        \
 } else if(!strncmp(OP, "max", 3)) {                                                                          \
-    BINARY_TYPE(DIM1,DIM2,OUT,IN1,MAX(*i1,*i2),IN2);                                                         \
+    if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
+        psError(__func__, ": Maximum operation not supported for complex numbers");                          \
+    } else {                                                                                                 \
+        BINARY_TYPE(DIM1,DIM2,OUT,IN1,fmax(*i1,*i2),IN2);                                                    \
+    }                                                                                                        \
 } else {                                                                                                     \
-    psError(__func__, ": Line %d - Invalid operator: %s", __LINE__, #OP);                                    \
+    psError(__func__, ": Invalid binary operator: %s", #OP);                                                 \
 }
 
