--- trunk/src/math/Polynomial.hpp 2006/01/30 22:25:27 876 +++ 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) { @@ -189,6 +189,22 @@ namespace oopse { 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) { typename Polynomial::const_iterator i; @@ -204,6 +220,7 @@ namespace oopse { for (i = p.begin(); i != p.end(); ++i) { this->addCoefficient(i->first, -i->second); } + return *this; } PolynomialType& operator *= (const PolynomialType& p) { @@ -310,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 @@ -334,7 +351,7 @@ namespace oopse { return true; } - typedef Polynomial DoublePolynomial; + typedef Polynomial DoublePolynomial; } //end namespace oopse #endif //MATH_POLYNOMIAL_HPP