From f9951a65dbe6241189c717b09db6a77df148cfd9 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Fri, 6 Feb 2026 12:04:13 -0500 Subject: [PATCH] update scalartypes --- Project.toml | 4 ++-- src/clebschgordan.jl | 2 +- src/sector.jl | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 72ef4b2..e50fcea 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SUNRepresentations" uuid = "1a50b95c-7aac-476d-a9ce-2bfc675fc617" authors = ["Maarten Van Damme , Jutho Haegeman and Lukas Devos "] -version = "0.3.4" +version = "0.3.5" [deps] JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" @@ -35,7 +35,7 @@ RationalRoots = "0.1 - 0.2" Scratch = "1" SparseArrayKit = "0.4" TensorKit = "0.15, 0.16" -TensorKitSectors = "0.3" +TensorKitSectors = "0.3.5" TensorOperations = "5" Test = "1" TestExtras = "0.3" diff --git a/src/clebschgordan.jl b/src/clebschgordan.jl index 5131d4b..6f93ef3 100644 --- a/src/clebschgordan.jl +++ b/src/clebschgordan.jl @@ -16,7 +16,7 @@ function weightmap(basis) return weights end -CGC(s1::I, s2::I, s3::I) where {I <: SUNIrrep} = CGC(Float64, s1, s2, s3) +CGC(s1::I, s2::I, s3::I) where {I <: SUNIrrep} = CGC(sectorscalartype(I), s1, s2, s3) function CGC(::Type{T}, s1::SUNIrrep{N}, s2::SUNIrrep{N}, s3::SUNIrrep{N}) where {T, N} return _get_CGC(T, (s1, s2, s3)) end diff --git a/src/sector.jl b/src/sector.jl index f43dbd6..41844eb 100644 --- a/src/sector.jl +++ b/src/sector.jl @@ -46,20 +46,24 @@ function TensorKitSectors.Nsymbol( return get(directproduct(s1, s2), s3, 0) end +TensorKitSectors.sectorscalartype(::Type{<:SUNIrrep}) = Float64 function TensorKitSectors.fusiontensor( s1::SUNIrrep{N}, s2::SUNIrrep{N}, s3::SUNIrrep{N} ) where {N} - return CGC(Float64, s1, s2, s3) + return CGC(s1, s2, s3) end const FCACHE = LRU{Int, Any}(; maxsize = 10) + +TensorKitSectors.fusionscalartype(::Type{<:SUNIrrep}) = Float64 + function TensorKitSectors.Fsymbol( a::SUNIrrep{N}, b::SUNIrrep{N}, c::SUNIrrep{N}, d::SUNIrrep{N}, e::SUNIrrep{N}, f::SUNIrrep{N} ) where {N} key = (a, b, c, d, e, f) K = typeof(key) - V = Array{Float64, 4} + V = Array{fusionscalartype(typeof(a)), 4} cache::LRU{K, V} = get!(FCACHE, N) do return LRU{K, V}(; maxsize = 10^5) end @@ -76,7 +80,8 @@ function _Fsymbol( N3 = Nsymbol(b, c, f) N4 = Nsymbol(a, f, d) - (N1 == 0 || N2 == 0 || N3 == 0 || N4 == 0) && return fill(0.0, N1, N2, N3, N4) + (N1 == 0 || N2 == 0 || N3 == 0 || N4 == 0) && + return fill(zero(fusionscalartype(typeof(a))), N1, N2, N3, N4) # computing first diagonal element A = fusiontensor(a, b, e) @@ -90,10 +95,11 @@ function _Fsymbol( end const RCACHE = LRU{Int, Any}(; maxsize = 10) +TensorKitSectors.braidingscalartype(::Type{<:SUNIrrep}) = Float64 function TensorKitSectors.Rsymbol(a::SUNIrrep{N}, b::SUNIrrep{N}, c::SUNIrrep{N}) where {N} key = (a, b, c) K = typeof(key) - V = Array{Float64, 2} + V = Array{braidingscalartype(typeof(a)), 2} cache::LRU{K, V} = get!(RCACHE, N) do return LRU{K, V}(; maxsize = 10^5) end @@ -105,7 +111,8 @@ function _Rsymbol(a::SUNIrrep{N}, b::SUNIrrep{N}, c::SUNIrrep{N}) where {N} N1 = Nsymbol(a, b, c) N2 = Nsymbol(b, a, c) - (N1 == 0 || N2 == 0) && return fill(0.0, N1, N2) + (N1 == 0 || N2 == 0) && + return fill(zero(braidingscalartype(typeof(a))), N1, N2) A = fusiontensor(a, b, c)[:, :, 1, :] B = fusiontensor(b, a, c)[:, :, 1, :]