-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Complex dot product doesn't conjugate #1761
Comments
Ah, that's interesting. The What would be needed to fix this behavior for complex values? Wrap the function in |
Yes, wrapping one of the vectors in
|
Thanks Michal!
|
Making a survey on how other applications do it is always a good idea! I checked Mathematica, Matlab and two Python libraries – Numpy and Scipy. I was surprised that only two of these four tools had a sesquilinear dot product. Both of them conjugated the first vector. MathematicaMathematica has a dot product which doesn't conjugate [discussion] [docs]. MatlabMatlab conjugates the first argument [docs] A = [1i 0];
B = [1 0];
dot(A, B)
% ans = 0.0000 - 1.0000i NumpyNumpy has two dot products. First one, >>> np.dot([2j, 3j], [2j, 3j])
(-13+0j) The second one is >>> a = np.array([1+2j,3+4j])
>>> b = np.array([5+6j,7+8j])
>>> np.vdot(a, b)
(70-8j)
>>> np.vdot(b, a)
(70+8j) SympyClassic sympy doesn't conjugate [live]: >>> M = Matrix([I, 0])
>>> M.dot(M)
-1 Sympy for QM conjugates symbolically, but since the operations are coordinate-independent, it's impossible to tell which of the vectors is conjugated [live]: >>> from sympy.physics.quantum import *
>>> A = Ket('A'); B = Ket('B')
>>> conjugate( Dagger(A) * B ) == Dagger(B) * A
True |
Sorry for the late reply. Thanks @m93a this is a very clear and useful overview! . So conclusions are:
|
Hey Jos, |
Inner product on ℂ is supposed to be sesquilinear – it should conjugate one of the two vectors before multiplying them. Source.
The current
dot
product clearly doesn't conjugate neither one of the vectors. This is also true ofmultiply(Vector, Vector)
which apparently has a different implementation thandot
.While the Wikipedia article I linked uses the convention <v, w> = vᵀ w̅ (inner product is linear in the first argument and antilinear in the second argument), the opposite convention <v, w> = v⁺ w = v̅ ᵀ w is used as often, if not more. (For example in quantum mechanics, the first argument is exclusively antilinear.)
The text was updated successfully, but these errors were encountered: