MCPcopy Index your code
hub / github.com/numpy/numpy / __mul__

Method __mul__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

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
itemsMethod · 0.80
maxFunction · 0.50

Tested by

no test coverage detected