Skip to content
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

[ITensors] [BUG] correlation_matrix() chokes on Pauli matrices X, Y (complex expectation value) #1609

Closed
christopherdavidwhite2 opened this issue Dec 20, 2024 · 2 comments
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.

Comments

@christopherdavidwhite2
Copy link

Description of bug

When I attempt to take the correlation matrix of the two Paulis X and Y, I get an InexactError

Minimal code demonstrating the bug

Minimal runnable code

L = 4
ss = ITensorMPS.siteinds("S=1/2",L)
ψ = MPS([state("Up", s) for s in ss])
correlation_matrix(ψ, "Y", "Z")

Curiously the same thing happens if I do ψ *= im to force the eltype of ψ's tensors to be complex.

Expected output or behavior

I expect im on the diagonal

Actual output or behavior

InexactError: Float64(0.0 + 1.0im)

Output of minimal runnable code

InexactError: Float64(0.0 + 1.0im)

Stacktrace:
  [1] Real
    @ ./complex.jl:44 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] setindex!
    @ ./genericmemory.jl:243 [inlined]
  [4] unsafe_copyto!(dest::Memory{Float64}, doffs::Int64, src::Memory{ComplexF64}, soffs::Int64, n::Int64)
    @ Base ./genericmemory.jl:153
  [5] unsafe_copyto!
    @ ./genericmemory.jl:133 [inlined]
  [6] _copyto_impl!
    @ ./array.jl:308 [inlined]
  [7] copyto!
    @ ./array.jl:294 [inlined]
  [8] copyto!
    @ ./array.jl:319 [inlined]
  [9] copyto_axcheck!
    @ ./abstractarray.jl:1167 [inlined]
 [10] Array
    @ ./array.jl:626 [inlined]
 [11] Array
    @ ./boot.jl:606 [inlined]
...
    @ ITensorMPS ~/.julia/packages/ITensorMPS/jyjxG/src/mps.jl:907
 [23] correlation_matrix(psi::MPS, _Op1::String, _Op2::String)
    @ ITensorMPS ~/.julia/packages/ITensorMPS/jyjxG/src/mps.jl:739
 [24] top-level scope
    @ ~/work/2024-11-SHADOW/src/MatrixProductShadows/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_W3sZmlsZQ==.jl:7

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M3
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_NUM_THREADS = 
  • Output from using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
[9136182c] ITensors v0.7.11
julia> using Pkg; Pkg.status("ITensorMPS")
[0d1a4710] ITensorMPS v0.3.3
@christopherdavidwhite2 christopherdavidwhite2 added bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. labels Dec 20, 2024
@mtfishman
Copy link
Member

Duplicate of ITensor/ITensorMPS.jl#79 (that issue started out as just about expect but it is the same issue in correlation_matrix and expect), see also https://itensor.discourse.group/t/correlation-matrix-of-complex-operators/584.

I'll close this in favor of ITensor/ITensorMPS.jl#79, also not that in the future MPS/MPO-related issues should be raised at https://github.com/ITensor/ITensorMPS.jl/issues.

@christopherdavidwhite2
Copy link
Author

got it---thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.
Projects
None yet
Development

No branches or pull requests

2 participants