(self, other)
| 467 | return NotImplemented |
| 468 | |
| 469 | def __mul__(self, other): |
| 470 | other = as_expr(other) |
| 471 | if isinstance(other, Expr): |
| 472 | if self.op is other.op: |
| 473 | if self.op in (Op.INTEGER, Op.REAL): |
| 474 | return as_number(self.data[0] * other.data[0], |
| 475 | max(self.data[1], other.data[1])) |
| 476 | elif self.op is Op.COMPLEX: |
| 477 | r1, i1 = self.data |
| 478 | r2, i2 = other.data |
| 479 | return as_complex(r1 * r2 - i1 * i2, r1 * i2 + r2 * i1) |
| 480 | |
| 481 | if self.op is Op.FACTORS: |
| 482 | r = Expr(self.op, dict(self.data)) |
| 483 | for k, v in other.data.items(): |
| 484 | _pairs_add(r.data, k, v) |
| 485 | return normalize(r) |
| 486 | elif self.op is Op.TERMS: |
| 487 | r = Expr(self.op, {}) |
| 488 | for t1, c1 in self.data.items(): |
| 489 | for t2, c2 in other.data.items(): |
| 490 | _pairs_add(r.data, t1 * t2, c1 * c2) |
| 491 | return normalize(r) |
| 492 | |
| 493 | if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL): |
| 494 | return self * as_complex(other) |
| 495 | elif other.op is Op.COMPLEX and self.op in (Op.INTEGER, Op.REAL): |
| 496 | return as_complex(self) * other |
| 497 | elif self.op is Op.REAL and other.op is Op.INTEGER: |
| 498 | return self * as_real(other, kind=self.data[1]) |
| 499 | elif self.op is Op.INTEGER and other.op is Op.REAL: |
| 500 | return as_real(self, kind=other.data[1]) * other |
| 501 | |
| 502 | if self.op is Op.TERMS: |
| 503 | return self * as_terms(other) |
| 504 | elif other.op is Op.TERMS: |
| 505 | return as_terms(self) * other |
| 506 | |
| 507 | return as_factors(self) * as_factors(other) |
| 508 | return NotImplemented |
| 509 | |
| 510 | def __rmul__(self, other): |
| 511 | if isinstance(other, number_types): |
nothing calls this directly
no test coverage detected