Index: trunk/psLib/src/math/psPolynomialMetadata.c
===================================================================
--- trunk/psLib/src/math/psPolynomialMetadata.c	(revision 11669)
+++ trunk/psLib/src/math/psPolynomialMetadata.c	(revision 15254)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-06 21:55:28 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-10-09 19:25:45 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -62,9 +62,9 @@
             // an undefined component implies the component was masked
             // this is symmetrical with the 1DtoMD function
-            poly->mask[nx] = 1;
             poly->coeff[nx] = 0;
             poly->coeffErr[nx] = 0;
+            poly->coeffMask[nx] = PS_POLY_MASK_SET;
         } else {
-            poly->mask[nx] = 0;
+            poly->coeffMask[nx] = PS_POLY_MASK_NONE;
             nElements ++;
         }
@@ -123,5 +123,5 @@
     // place polynomial entries on folder
     for (int nx = 0; nx < poly->nX + 1; nx++) {
-        if (poly->mask[nx] == 0) {
+        if (!(poly->coeffMask[nx] & PS_POLY_MASK_SET)) {
             sprintf(namespace, "VAL_X%02d", nx);
             sprintf(namespace_err, "ERR_X%02d", nx);
@@ -174,9 +174,9 @@
                 // an undefined component implies the component was masked
                 // this is symmetrical with the 2DtoMD function
-                poly->mask[nx][ny] = 1;
                 poly->coeff[nx][ny] = 0;
                 poly->coeffErr[nx][ny] = 0;
+                poly->coeffMask[nx][ny] = PS_POLY_MASK_SET;
             } else {
-                poly->mask[nx][ny] = 0;
+                poly->coeffMask[nx][ny] = PS_POLY_MASK_NONE;
                 nElements ++;
             }
@@ -203,14 +203,8 @@
     PS_ASSERT_PTR_NON_NULL(md, false);
     PS_ASSERT_PTR_NON_NULL(poly, false);
-    //XXX:  Current implementation only supports ordinary polynomials.
+
+    // XXX Current implementation only supports ordinary polynomials.
     if (poly->type != PS_POLYNOMIAL_ORD)
         return false;
-
-    // XXX I'm puzzled by this test.  a polynomial of 0 order with a value of 0 is a
-    // perfectly valid polynomial and can be written out.  a polynomial with all elements
-    // masked still carries information.
-    //Make sure polynomial isn't 0, completely empty
-    //if (poly->nX == 0 && poly->nY == 0 && poly->coeff[0][0] == 0)
-    //return false;
 
     int Nbyte;
@@ -245,5 +239,5 @@
     for (int nx = 0; nx < poly->nX + 1; nx++) {
         for (int ny = 0; ny < poly->nY + 1; ny++) {
-            if (poly->mask[nx][ny] == 0) {
+            if (!(poly->coeffMask[nx][ny] & PS_POLY_MASK_SET)) {
                 sprintf(namespace, "VAL_X%02d_Y%02d", nx, ny);
                 sprintf(namespace_err, "ERR_X%02d_Y%02d", nx, ny);
@@ -304,9 +298,9 @@
                     // an undefined component implies the component was masked
                     // this is symmetrical with the 3DtoMD function
-                    poly->mask[nx][ny][nz] = 1;
                     poly->coeff[nx][ny][nz] = 0;
                     poly->coeffErr[nx][ny][nz] = 0;
+                    poly->coeffMask[nx][ny][nz] = PS_POLY_MASK_SET;
                 } else {
-                    poly->mask[nx][ny][nz] = 0;
+                    poly->coeffMask[nx][ny][nz] = PS_POLY_MASK_NONE;
                     nElements ++;
                 }
@@ -370,5 +364,5 @@
         for (int ny = 0; ny < poly->nY + 1; ny++) {
             for (int nz = 0; nz < poly->nZ + 1; nz++) {
-                if (poly->mask[nx][ny][nz] == 0) {
+                if (!(poly->coeffMask[nx][ny][nz] & PS_POLY_MASK_SET)) {
                     sprintf(namespace, "VAL_X%02d_Y%02d_Z%02d", nx, ny, nz);
                     sprintf(namespace_err, "ERR_X%02d_Y%02d_Z%02d", nx, ny, nz);
@@ -437,9 +431,9 @@
                         // an undefined component implies the component was masked
                         // this is symmetrical with the 4DtoMD function
-                        poly->mask[nx][ny][nz][nt] = 1;
                         poly->coeff[nx][ny][nz][nt] = 0;
                         poly->coeffErr[nx][ny][nz][nt] = 0;
+                        poly->coeffMask[nx][ny][nz][nt] = PS_POLY_MASK_SET;
                     } else {
-                        poly->mask[nx][ny][nz][nt] = 0;
+                        poly->coeffMask[nx][ny][nz][nt] = PS_POLY_MASK_NONE;
                         nElements ++;
                     }
@@ -506,5 +500,5 @@
             for (int nz = 0; nz < poly->nZ + 1; nz++) {
                 for (int nt = 0; nt < poly->nT + 1; nt++) {
-                    if (poly->mask[nx][ny][nz][nt] == 0) {
+                    if (!(poly->coeffMask[nx][ny][nz][nt] & PS_POLY_MASK_SET)) {
                         sprintf(namespace, "VAL_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
                         sprintf(namespace_err, "ERR_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
