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
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FusionTensors"
uuid = "e16ca583-1f51-4df0-8e12-57d32947d33e"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.5.16"
version = "0.5.17"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -15,7 +15,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"

Expand All @@ -29,9 +28,8 @@ LRUCache = "1.6"
LinearAlgebra = "1.10"
Random = "1.10"
Strided = "2.3"
TensorAlgebra = "0.5.2"
TensorAlgebra = "0.6"
TensorKitSectors = "0.1, 0.2"
TensorProducts = "0.1.7"
TypeParameterAccessors = "0.4"
WignerSymbols = "2.0.0"
julia = "1.10"
1 change: 0 additions & 1 deletion src/fusion_trees/clebsch_gordan_tensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ using GradedArrays:
trivial,
zero_odd
using TensorAlgebra: contract
using TensorProducts: ⊗
import TensorKitSectors as TKS

function symbol_1j(s::SectorRange)
Expand Down
2 changes: 1 addition & 1 deletion src/fusion_trees/fusiontree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using GradedArrays:
AbstractGradedUnitRange,
SectorProductRange,
SectorRange,
⊗,
×,
arguments,
flip,
Expand All @@ -21,7 +22,6 @@ using GradedArrays:
to_gradedrange,
trivial
using TensorAlgebra: flatten_tuples
using TensorProducts: ⊗

#
# A fusion tree fuses N sectors sec1, secN onto one sector fused_sec. A given set of
Expand Down
8 changes: 4 additions & 4 deletions src/fusiontensor/fusiontensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ using GradedArrays:
sector_type,
sectormergesort,
sectors,
space_isequal
space_isequal,
trivial_gradedrange
using LinearAlgebra: UniformScaling
using Random: Random, AbstractRNG, randn!
using TensorAlgebra: BlockedTuple, trivial_axis, tuplemortar, length_codomain, length_domain
using TensorProducts: tensor_product
using TensorAlgebra: BlockedTuple, tuplemortar, length_codomain, length_domain
using TypeParameterAccessors: type_parameters

# ======================================= Misc ===========================================
Expand All @@ -36,7 +36,7 @@ function flip_domain(nonflipped_col_axis, nonflipped_trees_to_ranges)
end

function fuse_axes(::Type{S}, ::Tuple{}) where {S <: SectorRange}
fused_axis = trivial_axis(S)
fused_axis = trivial_gradedrange(S)
trees_to_ranges_mapping = Dict([SectorFusionTree{S}() => Block(1)[1:1]])
return fused_axis, trees_to_ranges_mapping
end
Expand Down
14 changes: 9 additions & 5 deletions src/fusiontensor/fusiontensoraxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ using GradedArrays:
AbstractGradedUnitRange,
SymmetryStyle,
TrivialSector,
⊗,
dual,
sector_type,
trivial
tensor_product,
trivial,
trivial_gradedrange
using TensorAlgebra:
TensorAlgebra,
AbstractBlockPermutation,
AbstractBlockTuple,
BlockedTuple,
length_codomain,
length_domain
using TensorProducts: ⊗
using TypeParameterAccessors: type_parameters

# ======================================= Misc ===========================================
Expand Down Expand Up @@ -68,7 +70,9 @@ end

TensorAlgebra.BlockedTuple(fta::FusionTensorAxes) = fta.outer_axes

TensorAlgebra.trivial_axis(fta::FusionTensorAxes) = trivial_axis(sector_type(fta))
function GradedArrays.trivial_gradedrange(fta::FusionTensorAxes)
return trivial_gradedrange(sector_type(fta))
end

TensorAlgebra.length_domain(fta::FusionTensorAxes) = length(domain(fta))

Expand Down Expand Up @@ -136,14 +140,14 @@ domain(fta::FusionTensorAxes) = fta[Block(2)]

function fused_codomain(fta::FusionTensorAxes)
if length_codomain(fta) == 0
return trivial_axis(fta)
return trivial_gradedrange(fta)
end
return ⊗(codomain(fta)...)
end

function fused_domain(fta::FusionTensorAxes)
if length_domain(fta) == 0
return dual(trivial_axis(fta))
return dual(trivial_gradedrange(fta))
end
return dual(⊗(dual.(domain(fta))...))
end
17 changes: 6 additions & 11 deletions src/fusiontensor/tensor_algebra_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using BlockArrays: Block
using GradedArrays: space_isequal
using LinearAlgebra: mul!
using TensorAlgebra: TensorAlgebra, AbstractBlockPermutation, FusionStyle, blockedperm,
blockedtrivialperm, genperm, matricize, unmatricize
genperm, matricize, trivialbiperm, unmatricize

function TensorAlgebra.output_axes(
::typeof(contract),
Expand Down Expand Up @@ -35,10 +35,9 @@ TensorAlgebra.FusionStyle(::Type{<:FusionTensor}) = FusionTensorFusionStyle()
unval(::Val{x}) where {x} = x

function TensorAlgebra.matricize(
::FusionTensorFusionStyle, ft::AbstractArray,
codomain_length::Val, domain_length::Val
::FusionTensorFusionStyle, ft::AbstractArray, length_codomain::Val
)
blocklengths(axes(ft)) == unval.((codomain_length, domain_length)) ||
first(blocklengths(axes(ft))) == unval(length_codomain) ||
throw(ArgumentError("Invalid trivial biperm"))
return FusionTensor(data_matrix(ft), (codomain_axis(ft),), (domain_axis(ft),))
end
Expand Down Expand Up @@ -118,13 +117,9 @@ const MATRIX_FUNCTIONS = [

for f in MATRIX_FUNCTIONS
@eval begin
function TensorAlgebra.$f(
a::FusionTensor,
codomain_length::Val, domain_length::Val;
kwargs...,
)
a_mat = matricize(a, codomain_length, domain_length)
biperm = blockedtrivialperm((codomain_length, domain_length))
function TensorAlgebra.$f(a::FusionTensor, length_codomain::Val; kwargs...)
a_mat = matricize(a, length_codomain)
biperm = trivialbiperm(length_codomain, Val(ndims(a)))
permuted_axes = axes(a)[biperm]
checkspaces_dual(codomain(permuted_axes), domain(permuted_axes))
fa_mat = set_data_matrix(a_mat, Base.$f(data_matrix(a_mat); kwargs...))
Expand Down
4 changes: 1 addition & 3 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ SUNRepresentations = "1a50b95c-7aac-476d-a9ce-2bfc675fc617"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -27,6 +26,5 @@ Random = "1.10"
SUNRepresentations = "0.3.1"
SafeTestsets = "0.1.0"
Suppressor = "0.2.8"
TensorAlgebra = "0.5"
TensorProducts = "0.1"
TensorAlgebra = "0.6"
Test = "1.10.0"
4 changes: 2 additions & 2 deletions test/test_array_cast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ using Test: @test, @test_throws, @testset
using BlockArrays: Block, BlockedArray, blocksize

using FusionTensors: FusionTensor, data_matrix, to_fusiontensor
using GradedArrays: O2, SU2, TrivialSector, U1, dual, gradedrange, sectorproduct
using TensorProducts: tensor_product
using GradedArrays: O2, SU2, TrivialSector, U1, dual, gradedrange, sectorproduct,
tensor_product

include("setup.jl")

Expand Down
4 changes: 2 additions & 2 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ using GradedArrays:
gradedrange,
sector_type,
sectorproduct,
space_isequal
space_isequal,
tensor_product
using TensorAlgebra: tuplemortar
using TensorProducts: tensor_product
using LinearAlgebra: LinearAlgebra, norm
using Random: Random

Expand Down
11 changes: 6 additions & 5 deletions test/test_fusiontensoraxes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Test: @test, @test_throws, @testset

using TensorProducts: ⊗
using BlockArrays: Block, blockedrange, blocklength, blocklengths, blocks
using TensorAlgebra: BlockedTuple, length_codomain, trivial_axis, tuplemortar

Expand All @@ -15,6 +14,7 @@ using FusionTensors:
promote_sector_type,
promote_sectors
using GradedArrays:
⊗,
×,
U1,
TrivialSector,
Expand All @@ -24,7 +24,8 @@ using GradedArrays:
gradedrange,
sectorproduct,
sector_type,
space_isequal
space_isequal,
trivial_gradedrange

@testset "misc FusionTensors.jl" begin
g1 = gradedrange([U1(0) => 1])
Expand Down Expand Up @@ -84,7 +85,7 @@ end
@test all(map(r -> space_isequal(r, g2b), domain(fta)))
@test space_isequal(fused_codomain(fta), g2 ⊗ g2)
@test space_isequal(fused_domain(fta), dual(g2 ⊗ g2))
@test space_isequal(trivial_axis(fta), trivial_axis(typeof(s2)))
@test space_isequal(trivial_gradedrange(fta), trivial_gradedrange(typeof(s2)))

@test fta == fta
@test copy(fta) == fta
Expand All @@ -111,7 +112,7 @@ end
@test length_codomain(fta) == 0

@test codomain(fta) == ()
@test space_isequal(fused_codomain(fta), trivial_axis(TrivialSector))
@test space_isequal(fused_codomain(fta), trivial_gradedrange(TrivialSector))
@test domain(fta) == ()
@test space_isequal(fused_domain(fta), dual(trivial_axis(TrivialSector)))
@test space_isequal(fused_domain(fta), dual(trivial_gradedrange(TrivialSector)))
end
Loading