Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 838
user2636742 Avatar asked Jun 23 '26 15:06

user2636742


1 Answers

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

like image 136
paxdiablo Avatar answered Jun 26 '26 13:06

paxdiablo