Index: /branches/rel-1_0/psLib/src/math/psPolynomial.c
===================================================================
--- /branches/rel-1_0/psLib/src/math/psPolynomial.c	(revision 12338)
+++ /branches/rel-1_0/psLib/src/math/psPolynomial.c	(revision 12339)
@@ -7,6 +7,6 @@
 *  polynomials.  It also contains a Gaussian functions.
 *
-*  @version $Revision: 1.157 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-01-09 22:38:53 $
+*  @version $Revision: 1.157.2.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-03-08 23:23:43 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -823,4 +823,78 @@
 }
 
+/************************************************************************************************************/
+/*
+ * Return the number of active terms in a polynomial
+ */
+int psPolynomial1DNterm(const psPolynomial1D *poly)
+{
+    PS_ASSERT_POLY_NON_NULL(poly, 0);
+
+    int nterm = 0;
+    for (int i = 0; i <= poly->nX; i++) {
+	if (poly->mask[i] == 0) {
+	    nterm++;
+	}
+    }
+
+    return nterm;
+}
+
+int psPolynomial2DNterm(const psPolynomial2D *poly)
+{
+    PS_ASSERT_POLY_NON_NULL(poly, 0);
+
+    int nterm = 0;
+    for (int i = 0; i <= poly->nX; i++) {
+	for (int j = 0; j <= poly->nY; j++) {
+	    if (poly->mask[j][i] == 0) {
+		nterm++;
+	    }
+	}
+    }
+
+    return nterm;
+}
+
+int psPolynomial3DNterm(const psPolynomial3D *poly)
+{
+    PS_ASSERT_POLY_NON_NULL(poly, 0);
+
+    int nterm = 0;
+    for (int i = 0; i <= poly->nX; i++) {
+	for (int j = 0; j <= poly->nY; j++) {
+	    for (int k = 0; k <= poly->nZ; k++) {
+		if (poly->mask[k][j][i] == 0) {
+		    nterm++;
+		}
+	    }
+	}
+    }
+
+    return nterm;
+}
+
+int psPolynomial4DNterm(const psPolynomial4D *poly)
+{
+    PS_ASSERT_POLY_NON_NULL(poly, 0);
+
+    int nterm = 0;
+    for (int i = 0; i <= poly->nX; i++) {
+	for (int j = 0; j <= poly->nY; j++) {
+	    for (int k = 0; k <= poly->nZ; k++) {
+		for (int l = 0; l <= poly->nT; l++) {
+		    if (poly->mask[l][k][j][i] == 0) {
+			nterm++;
+		    }
+		}
+	    }
+	}
+    }
+
+    return nterm;
+}
+
+/************************************************************************************************************/
+
 psF64 psPolynomial1DEval(const psPolynomial1D* poly,
                          psF64 x)
Index: /branches/rel-1_0/psLib/src/math/psPolynomial.h
===================================================================
--- /branches/rel-1_0/psLib/src/math/psPolynomial.h	(revision 12338)
+++ /branches/rel-1_0/psLib/src/math/psPolynomial.h	(revision 12339)
@@ -8,6 +8,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-01-23 22:47:23 $
+ * @version $Revision: 1.67.2.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-03-08 23:23:43 $
  *
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -145,4 +145,13 @@
     unsigned int nT                    ///< Number of terms in t
 );
+
+/** Return the number of terms in a 1-D polynomial */
+int psPolynomial1DNterm(const psPolynomial1D *poly);
+/** Return the number of terms in a 2-D polynomial */
+int psPolynomial2DNterm(const psPolynomial2D *poly);
+/** Return the number of terms in a 3-D polynomial */
+int psPolynomial3DNterm(const psPolynomial3D *poly);
+/** Return the number of terms in a 4-D polynomial */
+int psPolynomial4DNterm(const psPolynomial4D *poly);
 
 bool psPolynomial2DRecycle(psPolynomial2D *poly,
