Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorProducts"
uuid = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.1.1"
version = "0.1.2"

[weakdeps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand Down
11 changes: 2 additions & 9 deletions src/tensor_product.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ function require_one_based_axis(a::AbstractUnitRange)
end

# ============================== tensor product ==========================================
⊗() = tensor_product()
⊗(a) = tensor_product(a)

# default. No type restriction to allow sectors as input
⊗(a1, a2) = tensor_product(a1, a2)

# allow to specialize ⊗(a1, a2) to fusion_product
⊗(a1, a2, as...) = ⊗(⊗(a1, a2), as...)

tensor_product() = OneToOne()
tensor_product(a) = a
tensor_product(a1, a2, as...) = tensor_product(tensor_product(a1, a2), as...)
Expand All @@ -32,3 +23,5 @@ end
tensor_product(::OneToOne, ::OneToOne) = OneToOne()
tensor_product(::OneToOne, a::AbstractUnitRange) = tensor_product(a)
tensor_product(a::AbstractUnitRange, ::OneToOne) = tensor_product(a)

const ⊗ = tensor_product
18 changes: 6 additions & 12 deletions test/test_tensor_product.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ using BlockArrays: blockedrange, blockisequal
r0 = OneToOne()
b1 = blockedrange([1, 2])

@testset "⊗" begin
@test ⊗() isa OneToOne
@test ⊗(1:2) == 1:2
@test ⊗(1:2, 1:3) == 1:6
@test ⊗(1:2, 1:3, 1:4) == 1:24

@test ⊗(r0, r0) isa OneToOne
@test blockisequal(⊗(b1, b1), blockedrange([1, 2, 2, 4]))
@test blockisequal(⊗(b1, r0), b1)
@test blockisequal(⊗(r0, b1), b1)
end

@testset "tensor_product" begin
@test tensor_product() isa OneToOne
@test tensor_product(1:2) == 1:2
Expand All @@ -30,5 +18,11 @@ end
@test_throws ArgumentError tensor_product(2:3, 2:2)

@test tensor_product(r0, r0) isa OneToOne
@test blockisequal(tensor_product(b1, r0), b1)
@test blockisequal(tensor_product(r0, b1), b1)

@test blockisequal(tensor_product(b1, b1), blockedrange([1, 2, 2, 4]))
@test blockisequal(tensor_product(b1, b1), blockedrange([1, 2, 2, 4]))

@test ⊗(r0, r0) isa OneToOne
end
Loading