@ Operator in python? What means?

I have been programming for years in python, but now I was reading a program to perform linear 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 @ do in this code?

+3


source to share


1 answer


This is the matrix multiplication operator, described in PEP-465 and first done in Python 3.5 .



+5


source







All Articles