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 3445 by cpuglis, Fri Mar 7 19:37:14 2008 UTC vs.
Revision 3446 by cli2, Wed Sep 10 19:51:45 2008 UTC

# Line 129 | Line 129 | namespace oopse {
129       */
130          
131      void setCoefficient(int exponent, const ElemType& coefficient) {
132 <      polyPairMap_.insert(typename PolynomialPairMap::value_type(exponent, coefficient));
132 >      polyPairMap_[exponent] = coefficient;
133      }
134  
135      /**
# Line 149 | Line 149 | namespace oopse {
149        }
150      }
151  
152
152      /**
153       * Returns the coefficient associated with the given power for this Polynomial.
154       * @return the coefficient associated with the given power for this Polynomial
# Line 226 | Line 225 | namespace oopse {
225      PolynomialType& operator *= (const PolynomialType& p) {
226      typename Polynomial<ElemType>::const_iterator i;
227      typename Polynomial<ElemType>::const_iterator j;
228 <    
229 <    for (i = this->begin(); i !=this->end(); ++i) {
228 >    Polynomial<ElemType> p2(*this);
229 >  
230 >    polyPairMap_.clear();  // clear out old map
231 >    for (i = p2.begin(); i !=p2.end(); ++i) {
232        for (j = p.begin(); j !=p.end(); ++j) {
233          this->addCoefficient( i->first + j->first, i->second * j->second);
234        }
235 +    }
236 +    return *this;
237 +    }
238 +
239 +    //PolynomialType& operator *= (const ElemType v)
240 +    PolynomialType& operator *= (const ElemType v) {
241 +    typename Polynomial<ElemType>::const_iterator i;
242 +    //Polynomial<ElemType> result;
243 +
244 +    for (i = this->begin(); i != this->end(); ++i) {
245 +        this->setCoefficient( i->first, i->second*v);
246      }
247  
248      return *this;
249      }
250  
251 +    PolynomialType& operator += (const ElemType v) {    
252 +    this->addCoefficient( 0, v);
253 +    return *this;
254 +    }
255    
256    private:
257          
# Line 268 | Line 284 | namespace oopse {
284      Polynomial<ElemType> result;
285      
286      for (i = p.begin(); i !=p.end(); ++i) {
287 <        result.addCoefficient( i->first , i->second * v);
287 >        result.setCoefficient( i->first , i->second * v);
288      }
289  
290      return result;
# Line 280 | Line 296 | namespace oopse {
296      Polynomial<ElemType> result;
297      
298      for (i = p.begin(); i !=p.end(); ++i) {
299 <        result.addCoefficient( i->first , i->second * v);
299 >        result.setCoefficient( i->first , i->second * v);
300      }
301  
302      return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines