-
Notifications
You must be signed in to change notification settings - Fork 1
Define tensor_product
#2
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
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Thanks @ogauthe. Do you have a use case for |
Also, do we plan to define ⊗(r1::AbstractUnitRange, r2::AbstractUnitRange, r_rest::AbstractUnitRange...) = ⊗(⊗(r1, r2), r_rest...)
# Fallback definition
⊗(r1::AbstractUnitRange, r2::AbstractUnitRange) = tensor_product(r1, r2) Then in TensorProducts.:⊗(r1::AbstractGradedUnitRange, r2::AbstractGradedUnitRange) = fusion_product(r1, r2) |
I have no opinion on |
Relatedly, after we had discussed the idea for introducing this package, it made me wonder how |
I now allow to specialize I am unsure about |
I agree, ideally we wouldn't add that complexity here. The use case I have in mind is if you have a symmetric tensor (say a BlockSparseArray with graded axes) and you want to perform |
# This files defines the struct OneToOne | ||
# OneToOne represents the range `1:1` or `Base.OneTo(1)`. | ||
|
||
struct OneToOne{T} <: AbstractUnitRange{T} end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this obvious that we want this to be a separate type? Why not just use Base.OneTo(1)
?
I wouldn't expect this to be performance critical, and this is simply more work for the compiler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a dedicated OneToOne
can be useful as a dummy axis for the tensor product of zero axis.
# This files defines an interface for the tensor product of two axes | ||
# https://en.wikipedia.org/wiki/Tensor_product | ||
|
||
⊗() = tensor_product() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be an alias:
⊗() = tensor_product() | |
const ⊗ = tensor_product |
Then you could define methods for either, instead of both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not compatible with ⊗
being either tensor_product
or fusion_product
depending on the input.
ext/TensorProductsBlockArraysExt/TensorProductsBlockArraysExt.jl
Outdated
Show resolved
Hide resolved
Having |
Fine with me. |
I think this is ready to merge. |
Looks good to me as well, I'll merge. |
First step of the refactor detailed in ITensor/BlockSparseArrays.jl#57
OneToOne
,tensor_product
,dual
andflip
are now defined in this light weighted package.As we may get rid of
LabelledNumbers.jl
, I avoided having it as a dependency.