TensorKit.jl icon indicating copy to clipboard operation
TensorKit.jl copied to clipboard

Add fusionproduct

Open lkdvos opened this issue 1 year ago • 1 comments

Adds a non-unicode alternative to \otimes for sectors: fusionproduct.

Fixes #108 .

lkdvos avatar Mar 27 '24 10:03 lkdvos

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.40%. Comparing base (726c044) to head (f367a3e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #109   +/-   ##
=======================================
  Coverage   81.40%   81.40%           
=======================================
  Files          42       42           
  Lines        5565     5565           
=======================================
  Hits         4530     4530           
  Misses       1035     1035           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 27 '24 11:03 codecov[bot]

Probably needs some coverage :-). I am also wondering whether it is not better to really just have a unicode alternative to \otimes, that does not depend on the argument types (which is probably what you had suggested at first). Otherwise, we further complicate the interface. I would be fine with, otimes, tensorproduct, tensorprod. In TensorCore.jl, they simply call this tensor, but this is maybe a bit confusing (although one does read it like "a tensor b").

Jutho avatar Mar 29 '24 08:03 Jutho

I definitely also prefer having a fixed unicode alternative for this. It also creates less confusion when implementing the interface, as with the current implementation you would have to implement \otimes and not fusionproduct.

I do think tensor might be confusing, so I would vote otimes, and then use const ⊗ = otimes.

lkdvos avatar Mar 29 '24 09:03 lkdvos

Ok sounds good. However, I would keep using the actual unicode in all of the method definitions; I do like it more than the ascii otimes.

Jutho avatar Mar 29 '24 09:03 Jutho

I'll implement when I find some time.

Just for completeness: I double-checked and the alias thing works how you would expect: they are completely equivalent and defining methods for either implements them for both, so we can definitely just keep using the unicode everywhere.

julia> otimes(a, b) = a * b
otimes (generic function with 1 method)

julia> const ⊗ = otimes
otimes (generic function with 1 method)

julia> ⊗(a::Int, b::Int) = 2 * a * b
otimes (generic function with 2 methods)

julia> otimes(1, 2)
4

julia> ⊗(1, 2)
4

julia> 1 ⊗ 2
4

julia> ⊗(1.0, 2.0)
2.0

lkdvos avatar Mar 29 '24 10:03 lkdvos

I implemented the changes, and in the meantime also added a non-unicode alternative for oplus. As these are now true aliases, I don't think I need to add coverage?

lkdvos avatar Mar 30 '24 18:03 lkdvos