-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytriqs '*' operator is dot product -- not pythonic #599
Comments
Dear DerWeh, In principle I agree with you. However, if you take a rank 2 numpy.ndarray and you turn it into a matrix, import numpy as np
A = np.random.random((5, 5))
B = A * A # element wise product
M = np.mat(A)
C = M * M # matrix product I think the rationale for a matrix valued greens function is that it is matrix valued, and hence default to matrix multiplication. Do you have a more explicit example on how this gives unexpected behavior? Best, Hugo |
Yes, Gf are matrix valued by default. |
I agree that this would be much more consistent! |
Unfortunately the use numpy matrix is deprecated. |
Correct me if I am wrong, but it seems to me that you overloaded
*
with matrix multiplication.This is very contra-intuitive from a python point of view. I think it should be depreciated and a
dot
function should be introduced.The reason is simply consistency. In
numpy
, which is the basis for most scientific calculations in python,*
is element-wise multiplication.PEP 465 even introduces a dedicated infix operator for matrix multiplication (which is part of Python 3.5's syntax). This is the
@
operator.Hence, I think using
*
for matrix multiplication reduces readability. People familiar withnumpy
orpython
would expect and element-wise product.The text was updated successfully, but these errors were encountered: