ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/math/Polynomial.hpp
(Generate patch)

Comparing trunk/OOPSE-4/src/math/Polynomial.hpp (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2448 by tim, Wed Nov 16 23:10:02 2005 UTC

# Line 74 | Line 74 | namespace oopse {
74    class Polynomial {
75  
76    public:
77 <        
77 >    typedef Polynomial<ElemType> PolynomialType;    
78      typedef int ExponentType;
79      typedef ElemType CoefficientType;
80      typedef std::map<ExponentType, CoefficientType> PolynomialPairMap;
81      typedef typename PolynomialPairMap::iterator iterator;
82      typedef typename PolynomialPairMap::const_iterator const_iterator;
83 +
84 +    Polynomial() {}
85 +    Polynomial(ElemType v) {setCoefficient(0, v);}
86      /**
87       * Calculates the value of this Polynomial evaluated at the given x value.
88       * @return The value of this Polynomial evaluates at the given x value
# Line 185 | Line 188 | namespace oopse {
188      size_t size() {
189        return polyPairMap_.size();
190      }
191 <        
191 >
192 >    PolynomialType& operator += (const PolynomialType& p) {
193 >        typename Polynomial<ElemType>::const_iterator i;
194 >
195 >        for (i =  p.begin(); i  != p.end(); ++i) {
196 >          this->addCoefficient(i->first, i->second);
197 >        }
198 >
199 >        return *this;        
200 >    }
201 >
202 >    PolynomialType& operator -= (const PolynomialType& p) {
203 >        typename Polynomial<ElemType>::const_iterator i;
204 >        for (i =  p.begin(); i  != p.end(); ++i) {
205 >          this->addCoefficient(i->first, -i->second);
206 >        }        
207 >    }
208 >
209 >    PolynomialType& operator *= (const PolynomialType& p) {
210 >    typename Polynomial<ElemType>::const_iterator i;
211 >    typename Polynomial<ElemType>::const_iterator j;
212 >    
213 >    for (i = this->begin(); i !=this->end(); ++i) {
214 >      for (j = p.begin(); j !=p.end(); ++j) {
215 >        this->addCoefficient( i->first + j->first, i->second * j->second);
216 >      }
217 >    }
218 >
219 >    return *this;
220 >    }
221 >
222 >  
223    private:
224          
225      PolynomialPairMap polyPairMap_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines