QuantumSavory / QuantumSymbolics.jl

Computer algebra tools for symbolic manipulations in quantum mechanics and quantum information
MIT License
29 stars 9 forks source link

trace, partial trace, and superoperators #55

Closed apkille closed 1 month ago

apkille commented 2 months ago

Added trace and partial trace functionalities with examples and tests. Also created a symbolic superoperator SSuperOperator, including an option to express instances of this composite type in the Kraus representation with the function kraus. Future work can be done to create additional superoperator representations and conversions between each of them.

In the process of developing this branch, I encountered a few bugs mentioned in #53 and #54, which I fix in this PR.

apkille commented 2 months ago

The failed tests seem to come from the recent bumped compat for TermInterface #52, although most recent docs (https://juliasymbolics.github.io/TermInterface.jl/dev/) say that implementing sorted_arguments is optional.

 MethodError: no method matching sorted_arguments(::QuantumSymbolics.STrace)
│    
│    Closest candidates are:
│      sorted_arguments(::SymbolicUtils.PolyForm)
│       @ SymbolicUtils ~/.julia/packages/SymbolicUtils/dtCid/src/polyform.jl:235
│      sorted_arguments(::SymbolicUtils.BasicSymbolic)
│       @ SymbolicUtils ~/.julia/packages/SymbolicUtils/dtCid/src/types.jl:119
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 89.05109% with 15 lines in your changes missing coverage. Please review.

Project coverage is 74.23%. Comparing base (c9d8eed) to head (9f05adb).

Files Patch % Lines
src/QSymbolicsBase/basic_superops.jl 59.09% 9 Missing :warning:
src/QSymbolicsBase/linalg.jl 91.54% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #55 +/- ## ========================================== + Coverage 70.46% 74.23% +3.77% ========================================== Files 17 18 +1 Lines 650 753 +103 ========================================== + Hits 458 559 +101 - Misses 192 194 +2 ```

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

Krastanov commented 2 months ago

Just so that I do not get lost, could you point out in this comment thread what are the fixes for #53 and #54? And the corresponding test?

Krastanov commented 2 months ago

For the spellchecker issue, BA can be whitelisted in https://github.com/QuantumSavory/QuantumSymbolics.jl/blob/main/.typos.toml

apkille commented 2 months ago

I marked this PR as a draft because I first want to clean up the scaling and flattening functions, and also implement a qexpand function for expanding quantum expressions. Since this PR adds a lot of features, I would like to submit these changes in a separate PR.

Krastanov commented 2 months ago

The downstream buildkite error is known and unrelated.

Krastanov commented 2 months ago

Just FYI, QuantumInterface.jl provides some basis checking foundations and error types: https://github.com/qojulia/QuantumInterface.jl/blob/main/src/bases.jl#L140-L180