|
101 | 101 | @test !(V ≻ ⊞(V, V)) |
102 | 102 | end |
103 | 103 |
|
104 | | -@testset"GradedSpace" begin |
| 104 | +@testset "GradedSpace" begin |
105 | 105 | using TensorKit, BlockTensorKit |
106 | 106 | using Test, TestExtras |
107 | 107 |
|
@@ -153,3 +153,106 @@ end |
153 | 153 | @test V ≺ ⊞(V, V) |
154 | 154 | @test !(V ≻ ⊞(V, V)) |
155 | 155 | end |
| 156 | + |
| 157 | +@testset "Multifusion" begin |
| 158 | + using TensorKit, BlockTensorKit |
| 159 | + using Test, TestExtras |
| 160 | + |
| 161 | + using TensorKit: hassector |
| 162 | + using BlockTensorKit: ⊕ |
| 163 | + |
| 164 | + I = IsingBimodule |
| 165 | + |
| 166 | + C0, C1, D0, D1, M, Mop = I(1, 1, 0), I(1, 1, 1), I(2, 2, 0), I(2, 2, 1), I(1, 2, 0), I(2, 1, 0) |
| 167 | + |
| 168 | + V1 = Vect[I](C0 => 1, C1 => 1) |
| 169 | + V2 = Vect[I](D0 => 1, D1 => 1) |
| 170 | + V3 = Vect[I](M => 1) # no Mop |
| 171 | + d = dim(V1) + dim(V2) + dim(V3) |
| 172 | + V = SumSpace(V1, V2, V3) |
| 173 | + |
| 174 | + @test isa(V, VectorSpace) |
| 175 | + @test isa(V, ElementarySpace) |
| 176 | + |
| 177 | + @test isa(InnerProductStyle(V), HasInnerProduct) |
| 178 | + @test isa(InnerProductStyle(V), EuclideanInnerProduct) |
| 179 | + @test isa(V, SumSpace) |
| 180 | + |
| 181 | + @test !isdual(V) |
| 182 | + @test isdual(V') |
| 183 | + |
| 184 | + @test @constinferred(hash(V)) == hash(deepcopy(V)) |
| 185 | + @test @constinferred(dual(V)) == @constinferred(conj(V)) == @constinferred(adjoint(V)) |
| 186 | + @test field(V) == ℂ |
| 187 | + |
| 188 | + @test unitspace(V) == unitspace(V1) |
| 189 | + |
| 190 | + @test @constinferred(sectortype(V)) == sectortype(V1) |
| 191 | + @test ((@constinferred sectors(V))...,) == (C1, C0, D1, D0, M) # ordering matters |
| 192 | + @test length(sectors(V)) == 5 |
| 193 | + @test @constinferred(hassector(V, M)) |
| 194 | + @test !@constinferred(hassector(V, Mop)) |
| 195 | + @test @constinferred(dim(V)) == |
| 196 | + d == |
| 197 | + @constinferred(sum(dim(s) for s in sectors(V))) |
| 198 | + @test dim(@constinferred(typeof(V)())) == 0 |
| 199 | + @test (sectors(typeof(V)())...,) == () |
| 200 | + |
| 201 | + # (left/right)unitspace tests |
| 202 | + WC = @constinferred SumSpace(Vect[I](C0 => 1)) |
| 203 | + WD = @constinferred SumSpace(Vect[I](D0 => 1)) |
| 204 | + WM = @constinferred SumSpace(V3) |
| 205 | + WMop = @constinferred SumSpace(Vect[I](Mop => 1)) |
| 206 | + for W in [WC, WD] |
| 207 | + @test isunitspace(W) |
| 208 | + @test W == @constinferred(leftunitspace(W)) == @constinferred(rightunitspace(W)) |
| 209 | + @test unitspace(typeof(W)) == ⊞(Vect[IsingBimodule]((1, 1, 0) => 1, (2, 2, 0) => 1)) |
| 210 | + end |
| 211 | + |
| 212 | + @test_throws ArgumentError leftunitspace(V) |
| 213 | + @test_throws ArgumentError rightunitspace(V) |
| 214 | + @test leftunitspace(SumSpace(V1, V3)) == WC |
| 215 | + @test rightunitspace(SumSpace(V2, V3)) == WD |
| 216 | + @test leftunitspace(WMop) == WD && rightunitspace(WMop) == WC |
| 217 | + @test leftunitspace(WM) == WC && rightunitspace(WM) == WD |
| 218 | + @test unitspace(WM) == unitspace(WMop) == ⊞(Vect[IsingBimodule]((1, 1, 0) => 1, (2, 2, 0) => 1)) |
| 219 | + |
| 220 | + Wempty = SumSpace(Vect[I]()) |
| 221 | + Wzero = zerospace(V) |
| 222 | + @test unitspace(Wempty) == unitspace(Wzero) |
| 223 | + for f in (leftunitspace, rightunitspace) |
| 224 | + @test_throws ArgumentError f(Wempty) |
| 225 | + end |
| 226 | + |
| 227 | + VC = SumSpace(V1, V1) |
| 228 | + VCM = SumSpace(V1, V3) |
| 229 | + VMD = SumSpace(V2, V3) |
| 230 | + |
| 231 | + @test @constinferred(⊞(V, V)) == SumSpace(vcat(V.spaces, V.spaces)) |
| 232 | + @test @constinferred(⊞(VCM, unitspace(VCM))) == SumSpace(vcat(VCM.spaces, unitspace(VCM).spaces)) |
| 233 | + @test @constinferred(⊞(VCM, leftunitspace(VCM))) == SumSpace(vcat(VCM.spaces, leftunitspace(VCM).spaces)) |
| 234 | + @test @constinferred(⊞(VMD, rightunitspace(VMD))) == SumSpace(vcat(VMD.spaces, rightunitspace(VMD).spaces)) |
| 235 | + |
| 236 | + @test @constinferred(⊞(V, V, V, V)) == SumSpace(repeat(V.spaces, 4)) |
| 237 | + @test @constinferred(fuse(VC, VC)) ≅ SumSpace(Vect[I](C0 => 8, C1 => 8)) |
| 238 | + @test @constinferred(fuse(VC, VC', VC, VC')) ≅ |
| 239 | + SumSpace(Vect[I](C0 => 128, C1 => 128)) |
| 240 | + @test @constinferred(flip(V)) ≅ SumSpace(flip.(V.spaces)...) |
| 241 | + @test flip(V) ≅ V |
| 242 | + @test flip(V) ≾ V |
| 243 | + @test flip(V) ≿ V |
| 244 | + @test V ≺ ⊕(V, V) |
| 245 | + @test !(V ≻ ⊕(V, V)) |
| 246 | + |
| 247 | + # blocksectors tests |
| 248 | + @test issetequal(@constinferred(blocksectors(one(V) ← one(V))), (C0, D0)) |
| 249 | + @test issetequal(@constinferred(blocksectors(V ← V)), sectors(V)) |
| 250 | + @test @constinferred(blocksectors(one(V))) == [C0, D0] |
| 251 | + for v in [VC, VCM, VMD] |
| 252 | + @test @constinferred(blocksectors(v^2)) == blocksectors(v ← v) |
| 253 | + end |
| 254 | + for v in [WM, WMop] |
| 255 | + @test isempty(@constinferred(blocksectors(v^2))) |
| 256 | + @test @constinferred(blocksectors(v ← v)) == blocksectors(v) |
| 257 | + end |
| 258 | +end |
0 commit comments