204 |
|
for (i = p.begin(); i != p.end(); ++i) { |
205 |
|
this->addCoefficient(i->first, -i->second); |
206 |
|
} |
207 |
+ |
return *this; |
208 |
|
} |
209 |
|
|
210 |
|
PolynomialType& operator *= (const PolynomialType& p) { |
246 |
|
return p; |
247 |
|
} |
248 |
|
|
249 |
+ |
template<typename ElemType> |
250 |
+ |
Polynomial<ElemType> operator *(const Polynomial<ElemType>& p, const ElemType v) { |
251 |
+ |
typename Polynomial<ElemType>::const_iterator i; |
252 |
+ |
Polynomial<ElemType> result; |
253 |
+ |
|
254 |
+ |
for (i = p.begin(); i !=p.end(); ++i) { |
255 |
+ |
result.addCoefficient( i->first , i->second * v); |
256 |
+ |
} |
257 |
+ |
|
258 |
+ |
return result; |
259 |
+ |
} |
260 |
+ |
|
261 |
+ |
template<typename ElemType> |
262 |
+ |
Polynomial<ElemType> operator *( const ElemType v, const Polynomial<ElemType>& p) { |
263 |
+ |
typename Polynomial<ElemType>::const_iterator i; |
264 |
+ |
Polynomial<ElemType> result; |
265 |
+ |
|
266 |
+ |
for (i = p.begin(); i !=p.end(); ++i) { |
267 |
+ |
result.addCoefficient( i->first , i->second * v); |
268 |
+ |
} |
269 |
+ |
|
270 |
+ |
return result; |
271 |
+ |
} |
272 |
+ |
|
273 |
|
/** |
274 |
|
* Generates and returns the sum of two given Polynomials. |
275 |
|
* @param p1 the first polynomial |