def __mul__(self, other): if isinstance(other, Vector): if other._num_cols != 1: return ValueError(f'{other} should be general Vector') else: return sum(x * y for x, y in zip(self._values, other._values)) elif isinstance(other, Matrix): return Matrix.__mul__(self, other)
def __mul__(self, other): if isinstance(other, Vector): if other._num_rows != 1: raise ValueError(f'{other} should be transpose Vector') else: return sum(x * y for x, y in zip(self._values, other._values)) elif isinstance(other, Matrix): return Matrix.__mul__(self, other)