Skip to content

Commit efed80e

Browse files
committed
Restrict exp check to fermionic ITensors only
1 parent c019c65 commit efed80e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/tensor_operations/matrix_algebra.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ function exp(A::ITensor, Linds, Rinds; ishermitian=false)
6565
end
6666

6767
# <fermions>
68-
auto_fermion_enabled = using_auto_fermion()
69-
if auto_fermion_enabled
68+
fermionic_itensor = using_auto_fermion() && has_fermionic_subspaces(inds(A))
69+
if fermionic_itensor
7070
# If fermionic, bring indices into i',j',..,dag(j),dag(i)
7171
# ordering with Out indices coming before In indices
7272
# Resulting tensor acts like a normal matrix (no extra signs
@@ -95,7 +95,7 @@ function exp(A::ITensor, Linds, Rinds; ishermitian=false)
9595
expA = (itensor(expAT) * dag(CR)) * dag(CL)
9696

9797
# <fermions>
98-
if auto_fermion_enabled
98+
if fermionic_itensor
9999
# Ensure expA indices in "matrix" form before re-enabling fermion system
100100
expA = permute(expA, ordered_inds)
101101
enable_auto_fermion()

test/base/test_fermions.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@eval module $(gensym())
12
using ITensors, Test
23
import ITensors: Out, In
34
using ITensors.SiteTypes: op, siteind, siteinds
@@ -805,3 +806,5 @@ using ITensors.SiteTypes: op, siteind, siteinds
805806

806807
ITensors.disable_auto_fermion()
807808
end
809+
810+
end # module

test/base/test_qnitensor.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
@eval module $(gensym())
12
using ITensors
23
using ITensors.NDTensors
34
using ITensors.SiteTypes: siteind, siteinds
45
using LinearAlgebra
56
using Random
67
using Test
8+
using ITensors.SiteTypes: op
79

810
Random.seed!(1234)
911

@@ -1915,3 +1917,5 @@ Random.seed!(1234)
19151917
@test !ITensors.have_same_qns([QN(0) => 1, QN(0) => 2, QN(("Sz", 2)) => 1])
19161918
end
19171919
end
1920+
1921+
end # module

0 commit comments

Comments
 (0)