QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
918 stars 119 forks source link

Is there a built in function for concurrence / von-Neumann entropy / Schmidt decomposition? #443

Closed BoltzmannEntropy closed 1 year ago

BoltzmannEntropy commented 1 year ago

For entanglement testing. Thanks.

GiggleLiu commented 1 year ago

To my best knowledge, concurrence is not defined. For von-Neumann entropy, please check

julia> Yao.von_neumann_entropy

For Schmidt decomposition, it is just

julia> reg = rand_state(5)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

julia> focus!(reg, (1,2,4))  # separate the qubits into system and environment
ArrayReg{2, ComplexF64, Array...}
    active qubits: 3/5
    nlevel: 2

julia> using LinearAlgebra

julia> LinearAlgebra.svd(reg.state)
SVD{ComplexF64, Float64, Matrix{ComplexF64}, Vector{Float64}}
U factor:
8×4 Matrix{ComplexF64}:
 -0.261431-0.0960797im    0.260523+0.376523im    -0.237475+0.232969im    -0.389497-0.321233im
  -0.22806+0.25927im     0.0843631+0.161655im      0.45936-0.301496im   -0.0629732-0.0823107im
   0.32522+0.169679im     0.271214+0.362034im     0.535053+0.121561im     0.146547-0.000847907im
  0.223615+0.37805im     -0.128325+0.366616im    -0.254146-0.157601im    -0.201075-0.119976im
 -0.032563+0.0675164im   -0.234217+0.187352im     0.205174-0.305651im     -0.24895+0.110838im
 -0.315045+0.0352616im     0.51662-0.0836399im   -0.077368-0.0583198im    0.143729-0.38788im
 0.0166898+0.34663im    -0.0139973-0.0142509im  -0.0350241+0.105815im     0.315063-0.453482im
  0.326669-0.377421im    -0.175984-0.0799332im    0.185893+0.0710434im  -0.0332874-0.326603im
singular values:
4-element Vector{Float64}:
 0.6835581617109449
 0.531229886056492
 0.41629565712466526
 0.27792260357499565
Vt factor:
4×4 Matrix{ComplexF64}:
  0.459486+0.0im   0.558193-0.382603im  0.298438+0.160865im   0.322012-0.335073im
 -0.551793+0.0im  -0.165489-0.222685im  0.566234+0.44381im     0.25724+0.186518im
  0.252128+0.0im   0.158808-0.230465im  0.265749-0.336733im  -0.146302+0.807887im
  0.648713+0.0im  -0.597857+0.171156im  0.166966+0.394436im  0.0475861+0.0819934im