JuliaAttic / QuBase.jl

A foundational library for quantum mechanics in Julia
Other
43 stars 6 forks source link

Multiplication fix. #39

Closed amitjamadagni closed 9 years ago

amitjamadagni commented 9 years ago

The following case fails

julia> a = full(tensor(lowerop(2), QuArray(eye(2))))
4x4 QuMatrix in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,2}
[0.0 0.0 1.0 0.0
 0.0 0.0 0.0 1.0
 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0]

julia> sm = full(tensor(QuArray(eye(2)), lowerop(2)))
4x4 QuMatrix in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,2}
[0.0 1.0 0.0 0.0
 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 1.0
 0.0 0.0 0.0 0.0]

julia> a*sm'
4x4 QuMatrix in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,2}
[0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0
 0.0 1.0 0.0 0.0
 0.0 0.0 0.0 0.0]

the last one has to be

julia> a*sm'
4x4 QuMatrix in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,2}
[0.0 0.0 0.0 0.0
 0.0 0.0 1.0 0.0
 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0]
acroy commented 9 years ago

Well spotted! Could you add a test for this case? (I guess something like sigmax*sigmaz' vs coeffs(sigmax)*coeffs(sigmaz)' would be sufficient)

amitjamadagni commented 9 years ago

@acroy tests added and squashed. Ready to be merged !

amitjamadagni commented 9 years ago

@acroy I hope this is ready.