An example is converting the dimension names of a cache of messages to match that of the norm network:
function validate_message(nn::NormNetwork, message)
return if !any(name -> has_dimname(KetView(nn), name), dimnames(message))
error(
"provided message does not have have any index \
names in common with the tensor network contained in the norm."
)
end
end
function stateform(nn::NormNetwork, messages)
renamed_messages = map(messages) do msg
if !any(name -> has_dimname(KetView(nn), name), dimnames(msg))
error(
"provided message does not have have any index \
names in common with the tensor network contained in the norm."
)
end
bramap = Dict(codomainnames(msg) .=> Base.Fix1(braname, nn).(domainnames(msg)))
return replacedimnames(name -> get(bramap, name, name), state(msg))
end
return MessageCache(renamed_messages)
end
function operatorform(nn::NormNetwork, messages)
return messagecache(keys(messages)) do edge
validate_message(nn, messages[edge])
ketnames = linknames(KetView(nn), edge)
branames = linknames(BraView(nn), edge)
bramap = Dict(branames .=> Base.Fix1(braname, nn).(ketnames))
renamed_message = replacedimnames(name -> get(bramap, name, name), messages[edge])
return operator(renamed_message, branames, ketnames)
end
end
Originally posted by @jack-dunham in #119 (comment)
An example is converting the dimension names of a cache of messages to match that of the norm network:
Originally posted by @jack-dunham in #119 (comment)