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