Search code examples
pythonoperators

Operator @ in python? what does?


I have been programming for years in python but now i was reading a program to do linnear regression and i found this.

    if X.ndim == 1:
        X = X[:, None]
    d = X - self.mean
    precision = np.linalg.inv(self.var)
    return (
        np.exp(-0.5 * np.sum(d @ precision * d, axis=-1))
        * np.sqrt(np.linalg.det(precision))
        / np.power(2 * np.pi, 0.5 * self.ndim))

what does the @ in this code?


Solution

  • It's the matrix multiplication operator as described in PEP-465 and first made available in Python 3.5.