A common code pattern in ITensors.jl is analogous to the following:
using NamedDimsArrays: nameddims
a = nameddims(randn(2, 2), ("i", "j"))
b = nameddims(randn(2, 2), ("j", "k"))
q, r = qr(b, dimnames(a))
This fails right now because qr(::AbstractNamedDimsArray, codomain_names) is strict about the names that are input as the codomain names in the factorization, and dimnames(a) contains the name "i" which isn't a dimension name of b.
One can do:
q, r = qr(b, intersect(dimnames(b), dimnames(a)))
but that is a bit annoying to write which is why we automated it in ITensors.jl. We could have a keyword argument that toggles between the two:
# errors
q, r = qr(b, intersect(dimnames(b), dimnames(a)); strict=true)
# no error, equaivalent to `qr(b, intersect(dimnames(b), dimnames(a)))`, probably the default
q, r = qr(b, dimnames(a); strict=false)
Additionally, I think passing both the codomain and domain names should be strict, i.e.:
q, r = qr(b, dimnames(a), ("j",)) # errors
q, r = qr(b, ("i",), ("j",)) # works
q, r = qr(b, intersect(dimnames(b), dimnames(a)), setdiff(dimnames(b), dimnames(a))) # works
A common code pattern in
ITensors.jlis analogous to the following:This fails right now because
qr(::AbstractNamedDimsArray, codomain_names)is strict about the names that are input as the codomain names in the factorization, anddimnames(a)contains the name"i"which isn't a dimension name ofb.One can do:
but that is a bit annoying to write which is why we automated it in
ITensors.jl. We could have a keyword argument that toggles between the two:Additionally, I think passing both the codomain and domain names should be strict, i.e.: