Skip to content

Commit 3e0a23e

Browse files
committed
Add tests for both types of HPSD fermionic matrices
1 parent 64d554b commit 3e0a23e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/base/test_decomp.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,4 +500,46 @@ end
500500
@test norm(U * B - phi) < 1E-5
501501
@test dim(commonind(U, B)) <= 4
502502
end
503+
504+
@testset "Eigen of Fermionic Matrices" begin
505+
ITensors.enable_auto_fermion()
506+
s = Index([QN("Nf", 0, -1)=>2, QN("Nf", 1, -1)=>2], "s,Site,Fermion")
507+
t = Index([QN("Nf", 0, -1)=>2, QN("Nf", 1, -1)=>2], "t,Site,Fermion")
508+
509+
#
510+
# HPSD Operator (Out,In) case
511+
#
512+
M = random_itensor(s, dag(t))
513+
O = prime(M,s)*dag(M)
514+
515+
@test dir(inds(O)[1]) == ITensors.Out
516+
@test dir(inds(O)[2]) == ITensors.In
517+
linds = [s']
518+
rinds = [dag(s)]
519+
D_O, U = eigen(O, linds, rinds; ishermitian=true)
520+
@test norm(prime(U)*D_O*dag(U)-O) < 1E-10
521+
@test all(>=(0.),diag(array(D_O)))
522+
523+
println()
524+
525+
#
526+
# HPSD Dual operator (In,Out) case
527+
#
528+
# Make ρ out of two squared states
529+
# to populate both blocks: (0,0) and (1,1)
530+
ψ0 = random_itensor(t,s)
531+
ρ0 = prime(dag(ψ0),s)*ψ0
532+
533+
ψ2 = random_itensor(QN("Nf",2,-1),t,s)
534+
ρ2 = prime(dag(ψ2),s)*ψ2
535+
536+
ρ = ρ0/2 + ρ2/2
537+
@test dir(inds(ρ)[1]) == ITensors.In
538+
@test dir(inds(ρ)[2]) == ITensors.Out
539+
540+
D_ρ, U = eigen(ρ, [dag(s)'], [s]; ishermitian=true)
541+
@test all(>=(0.),diag(array(D_ρ)))
542+
@test norm(prime(U)*D_ρ*dag(U)-ρ) < 1E-10
543+
ITensors.disable_auto_fermion()
544+
end
503545
end

0 commit comments

Comments
 (0)