| 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 |
| 311 |
|
|
| 312 |
|
/** |
| 313 |
|
* Tests if two polynomial have the same exponents |
| 314 |
< |
* @return true if these all of the exponents in these Polynomial are identical |
| 314 |
> |
* @return true if all of the exponents in these Polynomial are identical |
| 315 |
|
* @param p1 the first polynomial |
| 316 |
|
* @param p2 the second polynomial |
| 317 |
|
* @note this function does not compare the coefficient |