Skip to content
Open
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
1 change: 1 addition & 0 deletions src/tensors/tensoroperations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ end

# `tdst = twist(permute(tsrc, p), twistmask)`, with the twist folded into the coefficients of the permutation
function permute_twist!(tdst::AbstractTensorMap, tsrc::AbstractTensorMap, p::Index2Tuple, twistmask, backend, allocator)
any(twistmask) || return TO.tensoradd!(tdst, tsrc, p, false, One(), Zero(), backend, allocator)
tsrc′, p′, _, conjsrc = _unwrap_source(tsrc, p, nothing, false)
return _braid!(tdst, tsrc′, p′, conjsrc, allind(tsrc′), twistmask, One(), Zero(), backend, allocator)
end
Expand Down
21 changes: 12 additions & 9 deletions src/tensors/treetransformers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ function recoupling_scalartype(::Type{A}, ::Type{Tₛ}) where {A, Tₛ <: Number
return Tₛ <: Real ? real(T) : complex(T)
end

function _treeindex(trees, f)
found, (_, i) = gettoken(trees, f)
found || throw(ArgumentError(lazy"fusion tree pair $f not found among the trees of the space"))
return i
end

# (coefficient, destination position, source position)
const UniqueTransformerData{T} = Tuple{T, Int, Int}

Expand Down Expand Up @@ -99,7 +105,7 @@ function UniqueTreeTransformer(::Type{A}, transform, p, Vdst::HomSpace, Vsrc::Ho

@timeit_debug GLOBAL_TIMER "symmetry: tree transform" for (isrc, (f₁, f₂)) in enumerate(src_trees)
f_dst, coeff = transform(conjsrc ? (f₂, f₁) : (f₁, f₂))
_, (_, idst) = gettoken(dst_trees, f_dst)
idst = _treeindex(dst_trees, f_dst)
data[isrc] = (convert(T, coeff), idst, isrc)
end

Expand Down Expand Up @@ -136,12 +142,10 @@ function GenericTreeTransformer(::Type{A}, transform, p, Vdst::HomSpace, Vsrc::H
@timeit_debug GLOBAL_TIMER "bookkeeping: subblock positions" begin
# the token into the fusion tree `Indices` is the subblock position
inds_src = map(fusiontrees(fs_src)) do (f₁, f₂)
_, (_, isrc) = gettoken(src_trees, conjsrc ? (f₂, f₁) : (f₁, f₂))
return isrc
return _treeindex(src_trees, conjsrc ? (f₂, f₁) : (f₁, f₂))
end
inds_dst = map(fusiontrees(fs_dst)) do f
_, (_, idst) = gettoken(dst_trees, f)
return idst
return _treeindex(dst_trees, f)
end
end
data[i] = (convert(Matrix{T}, U), inds_dst, inds_src)
Expand Down Expand Up @@ -280,19 +284,18 @@ function TraceTransformer(::Type{A}, Vdst::HomSpace, Vsrc::HomSpace, p::Index2Tu
for (isrc, f) in enumerate(src_trees)
trace_sectors_match(f, q) || continue
f′, coeff = planar_trace(f, p, q)
_, (_, idst) = gettoken(dst_trees, f′)
idst = _treeindex(dst_trees, f′)
addcolumn!([idst], [convert(T, coeff)], isrc)
end
else
for fs_src in fusionblocks(Vsrc)
trace_sectors_match(fs_src, q) || continue
fs_dst, U = planar_trace(fs_src, p, q)
inds_dst = map(fusiontrees(fs_dst)) do f
_, (_, idst) = gettoken(dst_trees, f)
return idst
return _treeindex(dst_trees, f)
end
for (i, f) in enumerate(fusiontrees(fs_src))
_, (_, isrc) = gettoken(src_trees, f)
isrc = _treeindex(src_trees, f)
addcolumn!(inds_dst, convert(Vector{T}, U[:, i]), isrc)
end
end
Expand Down
Loading