MCPcopy Create free account
hub / github.com/numpy/numpy / __mul__

Method __mul__

numpy/f2py/symbolic.py:469–508  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 10

as_exprFunction · 0.85
as_numberFunction · 0.85
as_complexFunction · 0.85
ExprClass · 0.85
_pairs_addFunction · 0.85
normalizeFunction · 0.85
as_realFunction · 0.85
as_termsFunction · 0.85
as_factorsFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected