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 = "KroneckerArrays"
uuid = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.3.5"
version = "0.3.6"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ struct KroneckerFusion{A <: FusionStyle, B <: FusionStyle} <: FusionStyle
a::A
b::B
end
function KroneckerFusion{A, B}() where {A <: FusionStyle, B <: FusionStyle}
return KroneckerFusion{A, B}(A(), B())
end
KroneckerArrays.kroneckerfactors(style::KroneckerFusion) = (style.a, style.b)
KroneckerArrays.kroneckerfactortypes(::Type{KroneckerFusion{A, B}}) where {A, B} = (A, B)
function KroneckerArrays.:⊗(style1::FusionStyle, style2::FusionStyle)
return KroneckerFusion(style1, style2)
end

function TensorAlgebra.FusionStyle(A::Type{<:AbstractKroneckerArray})
return KroneckerFusion(FusionStyle.(kroneckerfactortypes(A))...)
Expand Down
11 changes: 10 additions & 1 deletion test/test_tensoralgebra.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
using TensorAlgebra: matricize, tensor_product_axis, trivial_axis, unmatricize
using TensorAlgebra: FusionStyle, ReshapeFusion, matricize, tensor_product_axis,
trivial_axis, unmatricize
using KroneckerArrays: ⊗, cartesianrange, kroneckerfactors, unproduct
using Test: @test, @testset

@testset "TensorAlgebraExt" begin
@testset "FusionStyle" begin
a1 = randn(2, 2, 2)
a2 = randn(2, 2, 2)
a = a1 ⊗ a2
@test FusionStyle(a) ≡ ReshapeFusion() ⊗ ReshapeFusion()
@test kroneckerfactors(FusionStyle(a)) ≡ (ReshapeFusion(), ReshapeFusion())
@test typeof(FusionStyle(a))() ≡ FusionStyle(a)
end
@testset "tensor_product_axis" begin
r = cartesianrange(2, 3)
@test trivial_axis(r) ≡ cartesianrange(1, 1)
Expand Down
Loading