diff --git a/Project.toml b/Project.toml index f10c911..346953d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TensorAlgebra" uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a" authors = ["ITensor developers and contributors"] -version = "0.2.3" +version = "0.2.4" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" @@ -9,22 +9,17 @@ BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4" +TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d" TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" -[weakdeps] -GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5" - -[extensions] -TensorAlgebraGradedUnitRangesExt = "GradedUnitRanges" - [compat] ArrayLayouts = "1.10.4" -BlockArrays = "1.2.0" +BlockArrays = "1.5.0" EllipsisNotation = "1.8.0" -GradedUnitRanges = "0.1.0" LinearAlgebra = "1.10" MatrixAlgebraKit = "0.1.1" +TensorProducts = "0.1.0" TupleTools = "1.6.0" TypeParameterAccessors = "0.2.1, 0.3" julia = "1.10" diff --git a/ext/TensorAlgebraGradedUnitRangesExt/TensorAlgebraGradedUnitRangesExt.jl b/ext/TensorAlgebraGradedUnitRangesExt/TensorAlgebraGradedUnitRangesExt.jl deleted file mode 100644 index fe7caa2..0000000 --- a/ext/TensorAlgebraGradedUnitRangesExt/TensorAlgebraGradedUnitRangesExt.jl +++ /dev/null @@ -1,8 +0,0 @@ -module TensorAlgebraGradedUnitRangesExt -using GradedUnitRanges: AbstractGradedUnitRange, tensor_product -using TensorAlgebra: TensorAlgebra - -function TensorAlgebra.:⊗(a1::AbstractGradedUnitRange, a2::AbstractGradedUnitRange) - return tensor_product(a1, a2) -end -end diff --git a/src/fusedims.jl b/src/fusedims.jl index 38205c8..87bab85 100644 --- a/src/fusedims.jl +++ b/src/fusedims.jl @@ -1,3 +1,4 @@ +using TensorProducts: ⊗ using .BaseExtensions: _permutedims, _permutedims! abstract type FusionStyle end @@ -21,13 +22,6 @@ function fusedims(::ReshapeFusion, a::AbstractArray, axes::AbstractUnitRange...) return reshape(a, axes) end -⊗(a::AbstractUnitRange) = a -function ⊗(a1::AbstractUnitRange, a2::AbstractUnitRange, as::AbstractUnitRange...) - return ⊗(a1, ⊗(a2, as...)) -end -⊗(a1::AbstractUnitRange, a2::AbstractUnitRange) = Base.OneTo(length(a1) * length(a2)) -⊗() = Base.OneTo(1) - # Overload this version for most arrays function fusedims(a::AbstractArray, ax::AbstractUnitRange, axes::AbstractUnitRange...) return fusedims(FusionStyle(a), a, ax, axes...) diff --git a/test/test_blockarrays_contract.jl b/test/test_blockarrays_contract.jl index e7754b0..c3b3af8 100644 --- a/test/test_blockarrays_contract.jl +++ b/test/test_blockarrays_contract.jl @@ -31,7 +31,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) ) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockedArray + @test a_dest isa BlockedArray{elt} @test a_dest ≈ a_dest_dense # matrix vector @@ -39,15 +39,15 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) a_dest_dense, dimnames_dest_dense = contract(a1_dense, (2, -1, -2, 1), a3_dense, (1, 2)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockedArray + @test a_dest isa BlockedArray{elt} @test a_dest ≈ a_dest_dense - # vector matrix + # vector matrix a_dest, dimnames_dest = contract(a3, (1, 2), a1, (2, -1, -2, 1)) a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a1_dense, (2, -1, -2, 1)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockedArray + @test a_dest isa BlockedArray{elt} @test a_dest ≈ a_dest_dense # vector vector @@ -63,7 +63,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) a_dest, dimnames_dest = contract(a3, (1, 2), a3, (3, 4)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockedArray + @test a_dest isa BlockedArray{elt} @test a_dest ≈ a_dest_dense end @@ -77,7 +77,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) ) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockArray + @test a_dest isa BlockArray{elt} @test a_dest ≈ a_dest_dense # matrix vector @@ -85,15 +85,15 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) a_dest_dense, dimnames_dest_dense = contract(a1_dense, (2, -1, -2, 1), a3_dense, (1, 2)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockArray + @test a_dest isa BlockArray{elt} @test a_dest ≈ a_dest_dense - # vector matrix + # vector matrix a_dest, dimnames_dest = contract(a3, (1, 2), a1, (2, -1, -2, 1)) a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a1_dense, (2, -1, -2, 1)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockArray + @test a_dest isa BlockArray{elt} @test a_dest ≈ a_dest_dense # vector vector @@ -109,7 +109,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a3_dense, (3, 4)) @test dimnames_dest == dimnames_dest_dense @test size(a_dest) == size(a_dest_dense) - @test a_dest isa BlockArray + @test a_dest isa BlockArray{elt} @test a_dest ≈ a_dest_dense end end diff --git a/test/test_gradedunitrangesext_basics.jl b/test/test_gradedunitrangesext_basics.jl deleted file mode 100644 index 16a83a3..0000000 --- a/test/test_gradedunitrangesext_basics.jl +++ /dev/null @@ -1,31 +0,0 @@ -using BlockArrays: Block -using TensorAlgebra: ⊗ -using GradedUnitRanges: GradedUnitRanges, gradedrange, dual, isdual, label -using SymmetrySectors: U1 -using Test: @test, @testset - -@testset "TensorAlgebraGradedUnitRangesExt" begin - a1 = gradedrange([U1(0) => 2, U1(1) => 3]) - a2 = gradedrange([U1(2) => 3, U1(3) => 4]) - a = a1 ⊗ a2 - @test label(a[Block(1)]) == U1(2) - @test label(a[Block(2)]) == U1(3) - @test label(a[Block(3)]) == U1(3) - @test label(a[Block(4)]) == U1(4) - @test a[Block(1)] == 1:6 - @test a[Block(2)] == 7:15 - @test a[Block(3)] == 16:23 - @test a[Block(4)] == 24:35 - @test !isdual(a) - - a = a1 ⊗ dual(a2) - @test label(a[Block(1)]) == U1(-2) - @test label(a[Block(2)]) == U1(-1) - @test label(a[Block(3)]) == U1(-3) - @test label(a[Block(4)]) == U1(-2) - @test a[Block(1)] == 1:6 - @test a[Block(2)] == 7:15 - @test a[Block(3)] == 16:23 - @test a[Block(4)] == 24:35 - @test !isdual(a) -end