Skip to content

Commit 59cd3fb

Browse files
committed
Replace dag and dual stubs with Base.conj
`Base.conj` is the standard name for the bra-side involution (data conj + per-axis arrow flip, no transpose) across the symmetric-tensor ecosystem (TeNPy, YASTN, symmray, Google TensorNetwork). It also lets graded matrices inherit `m'` and `m' * m` for free via Julia's standard `AbstractMatrix` machinery (`Base.adjoint = conj ∘ transpose`). Drops the local `dag(x) = x` and `dual(x) = x` stubs in `src/tensoralgebra.jl` and replaces calls in `similar_operator`, `normnetwork`, and `insert_trivial_link!`. For non-graded backings the new behavior is the standard `Base.conj` default; graded backends will overload `Base.conj` on their array and axis types without needing to touch INN.
1 parent e670500 commit 59cd3fb

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/abstracttensornetwork.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function insert_trivial_link!(tn, e)
187187
x = similar(tn[src(e)], (l,))
188188
x[1] = 1
189189
@preserve_graph tn[src(e)] = tn[src(e)] * x
190-
@preserve_graph tn[dst(e)] = tn[dst(e)] * dag(x)
190+
@preserve_graph tn[dst(e)] = tn[dst(e)] * conj(x)
191191
return tn
192192
end
193193

src/beliefpropagation/normnetwork.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function normnetwork(tn)
129129
norm_tn = TensorNetwork(underlying_graph(tn)) do v
130130
t = tn[v]
131131
ket_to_bra = Dict(p for e in incident_edges(tn, v) for p in linknames_map[e])
132-
return t * replacedimnames(n -> get(ket_to_bra, n, n), dag(t))
132+
return t * replacedimnames(n -> get(ket_to_bra, n, n), conj(t))
133133
end
134134
return norm_tn, linknames_map
135135
end

src/tensoralgebra.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,19 @@ using TensorAlgebra: TensorAlgebra, AbstractBlockPermutation, FusionStyle, biper
2121
# for the same piracy reason, plus to hide the workaround for the ITensor
2222
# `eltype(::Type) === Any` issue (peeling to the concrete storage so the
2323
# stdlib `randn!` / `rand!` sees the runtime eltype).
24-
# - `dag`, `dual` — no-op stubs for the tensor and axis involutions.
25-
26-
# Tensor-algebra interface no-op stubs. Currently identity; backends (graded sectors,
27-
# complex tensors, etc.) will overload these for their semantics.
2824
#
29-
# `dag` is the involution on TENSORS (conjugate-transpose, sector-direction flip, …).
30-
# `dual` is the involution on AXES (vector space → dual vector space).
31-
dag(x) = x
32-
dual(x) = x
25+
# `Base.conj` is the bra-side involution (op A: data conj + arrow flip on every leg,
26+
# no transpose) used at both the tensor and axis layer. For non-graded backings the
27+
# default `Base.conj` is correct (elementwise data conj on tensors; identity on plain
28+
# axes). Graded backends overload `Base.conj` on their array and axis types to flip
29+
# sector arrows in addition to the data conj.
3330

3431
# Allocate a square operator with the given `codomain` named axes. Domain axes are
35-
# derived as `dual.(codomain)` with fresh `randname`-generated names; backend / device
32+
# derived as `conj.(codomain)` with fresh `randname`-generated names; backend / device
3633
# inherited from `prototype` via `Base.similar`.
3734
function similar_operator(prototype, ::Type{T}, codomain) where {T}
3835
domain_names = randname.(name.(codomain))
39-
domain_axes = setname.(dual.(codomain), domain_names)
36+
domain_axes = setname.(conj.(codomain), domain_names)
4037
raw = similar(prototype, T, (codomain..., domain_axes...))
4138
return operator(raw, name.(codomain), domain_names)
4239
end

0 commit comments

Comments
 (0)