--- trunk/src/math/Polynomial.hpp 2006/02/01 17:26:43 877 +++ trunk/src/math/Polynomial.hpp 2008/03/07 19:37:14 1230 @@ -53,7 +53,7 @@ #include #include #include - +#include "config.h" namespace oopse { template ElemType pow(ElemType x, int N) { @@ -187,6 +187,22 @@ namespace oopse { size_t size() { return polyPairMap_.size(); + } + + PolynomialType& operator = (const PolynomialType& p) { + + if (this != &p) // protect against invalid self-assignment + { + typename Polynomial::const_iterator i; + + polyPairMap_.clear(); // clear out the old map + + for (i = p.begin(); i != p.end(); ++i) { + this->setCoefficient(i->first, i->second); + } + } + // by convention, always return *this + return *this; } PolynomialType& operator += (const PolynomialType& p) { @@ -311,7 +327,7 @@ namespace oopse { /** * Tests if two polynomial have the same exponents - * @return true if these all of the exponents in these Polynomial are identical + * @return true if all of the exponents in these Polynomial are identical * @param p1 the first polynomial * @param p2 the second polynomial * @note this function does not compare the coefficient @@ -335,7 +351,7 @@ namespace oopse { return true; } - typedef Polynomial DoublePolynomial; + typedef Polynomial DoublePolynomial; } //end namespace oopse #endif //MATH_POLYNOMIAL_HPP