Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Ignore extraneous dimension names in qr/svd #22

Open
mtfishman opened this issue Jan 17, 2025 · 1 comment
Open

[ENHANCEMENT] Ignore extraneous dimension names in qr/svd #22

mtfishman opened this issue Jan 17, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@mtfishman
Copy link
Member

mtfishman commented Jan 17, 2025

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
@mtfishman mtfishman added the enhancement New feature or request label Jan 17, 2025
@mtfishman
Copy link
Member Author

mtfishman commented Jan 17, 2025

Note that qr(::AbstractNamedDimsArray, ...)/svd(::AbstractNamedDimsArray, ...) forward to TensorAlgebra.qr/TensorAlgebra.svd and this discussion is relevant for that package as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant