Skip to content

Commit c719559

Browse files
authored
adapt to TensorProducts (#41)
1 parent ff08635 commit c719559

File tree

5 files changed

+15
-65
lines changed

5 files changed

+15
-65
lines changed

Project.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
name = "TensorAlgebra"
22
uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.3"
4+
version = "0.2.4"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
88
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
99
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
12+
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
1213
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
1314
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
1415

15-
[weakdeps]
16-
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
17-
18-
[extensions]
19-
TensorAlgebraGradedUnitRangesExt = "GradedUnitRanges"
20-
2116
[compat]
2217
ArrayLayouts = "1.10.4"
23-
BlockArrays = "1.2.0"
18+
BlockArrays = "1.5.0"
2419
EllipsisNotation = "1.8.0"
25-
GradedUnitRanges = "0.1.0"
2620
LinearAlgebra = "1.10"
2721
MatrixAlgebraKit = "0.1.1"
22+
TensorProducts = "0.1.0"
2823
TupleTools = "1.6.0"
2924
TypeParameterAccessors = "0.2.1, 0.3"
3025
julia = "1.10"

ext/TensorAlgebraGradedUnitRangesExt/TensorAlgebraGradedUnitRangesExt.jl

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/fusedims.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using TensorProducts:
12
using .BaseExtensions: _permutedims, _permutedims!
23

34
abstract type FusionStyle end
@@ -21,13 +22,6 @@ function fusedims(::ReshapeFusion, a::AbstractArray, axes::AbstractUnitRange...)
2122
return reshape(a, axes)
2223
end
2324

24-
(a::AbstractUnitRange) = a
25-
function (a1::AbstractUnitRange, a2::AbstractUnitRange, as::AbstractUnitRange...)
26-
return (a1, (a2, as...))
27-
end
28-
(a1::AbstractUnitRange, a2::AbstractUnitRange) = Base.OneTo(length(a1) * length(a2))
29-
() = Base.OneTo(1)
30-
3125
# Overload this version for most arrays
3226
function fusedims(a::AbstractArray, ax::AbstractUnitRange, axes::AbstractUnitRange...)
3327
return fusedims(FusionStyle(a), a, ax, axes...)

test/test_blockarrays_contract.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
3131
)
3232
@test dimnames_dest == dimnames_dest_dense
3333
@test size(a_dest) == size(a_dest_dense)
34-
@test a_dest isa BlockedArray
34+
@test a_dest isa BlockedArray{elt}
3535
@test a_dest a_dest_dense
3636

3737
# matrix vector
3838
a_dest, dimnames_dest = contract(a1, (2, -1, -2, 1), a3, (1, 2))
3939
a_dest_dense, dimnames_dest_dense = contract(a1_dense, (2, -1, -2, 1), a3_dense, (1, 2))
4040
@test dimnames_dest == dimnames_dest_dense
4141
@test size(a_dest) == size(a_dest_dense)
42-
@test a_dest isa BlockedArray
42+
@test a_dest isa BlockedArray{elt}
4343
@test a_dest a_dest_dense
4444

45-
# vector matrix
45+
# vector matrix
4646
a_dest, dimnames_dest = contract(a3, (1, 2), a1, (2, -1, -2, 1))
4747
a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a1_dense, (2, -1, -2, 1))
4848
@test dimnames_dest == dimnames_dest_dense
4949
@test size(a_dest) == size(a_dest_dense)
50-
@test a_dest isa BlockedArray
50+
@test a_dest isa BlockedArray{elt}
5151
@test a_dest a_dest_dense
5252

5353
# vector vector
@@ -63,7 +63,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
6363
a_dest, dimnames_dest = contract(a3, (1, 2), a3, (3, 4))
6464
@test dimnames_dest == dimnames_dest_dense
6565
@test size(a_dest) == size(a_dest_dense)
66-
@test a_dest isa BlockedArray
66+
@test a_dest isa BlockedArray{elt}
6767
@test a_dest a_dest_dense
6868
end
6969

@@ -77,23 +77,23 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
7777
)
7878
@test dimnames_dest == dimnames_dest_dense
7979
@test size(a_dest) == size(a_dest_dense)
80-
@test a_dest isa BlockArray
80+
@test a_dest isa BlockArray{elt}
8181
@test a_dest a_dest_dense
8282

8383
# matrix vector
8484
a_dest, dimnames_dest = contract(a1, (2, -1, -2, 1), a3, (1, 2))
8585
a_dest_dense, dimnames_dest_dense = contract(a1_dense, (2, -1, -2, 1), a3_dense, (1, 2))
8686
@test dimnames_dest == dimnames_dest_dense
8787
@test size(a_dest) == size(a_dest_dense)
88-
@test a_dest isa BlockArray
88+
@test a_dest isa BlockArray{elt}
8989
@test a_dest a_dest_dense
9090

91-
# vector matrix
91+
# vector matrix
9292
a_dest, dimnames_dest = contract(a3, (1, 2), a1, (2, -1, -2, 1))
9393
a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a1_dense, (2, -1, -2, 1))
9494
@test dimnames_dest == dimnames_dest_dense
9595
@test size(a_dest) == size(a_dest_dense)
96-
@test a_dest isa BlockArray
96+
@test a_dest isa BlockArray{elt}
9797
@test a_dest a_dest_dense
9898

9999
# vector vector
@@ -109,7 +109,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
109109
a_dest_dense, dimnames_dest_dense = contract(a3_dense, (1, 2), a3_dense, (3, 4))
110110
@test dimnames_dest == dimnames_dest_dense
111111
@test size(a_dest) == size(a_dest_dense)
112-
@test a_dest isa BlockArray
112+
@test a_dest isa BlockArray{elt}
113113
@test a_dest a_dest_dense
114114
end
115115
end

test/test_gradedunitrangesext_basics.jl

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)