Conversion of symbolic objects to base linear algebra objects (vectors, matrices, sparse matrices, etc)
enhancement
This is one of 3 independent bounties which share the type of work that needs to be done:
- #116 on interfacing with QuantumToolbox.jl
- #117 on improving the interface that already exists for QuantumOptics.jl
- #118 on using the already existing QuantumOptics.jl interface to provide an interface for unstructured "naked" state vectors and operators
One of the main value-adds of QuantumSymbolics.jl is to enable converting symbolic expressions into the appropriate numerical representation for use with a variety of simulators. We have such capabilities with respect to a few simulators now, e.g. converting the symbolic `Z1` into either a Ket (from `QuantumOptics.jl`) or a Stabilizer tableau (from `QuantumClifford.jl`). Here is an example:
```
julia> using QuantumSavory, QuantumOpticsBase, QuantumClifford
julia> express(X1, QuantumOpticsRepr())
Ket(dim=2)
basis: Spin(1/2)
0.7071067811865475 + 0.0im
0.7071067811865475 + 0.0im
julia> express(X1, CliffordRepr())
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
𝒮𝓉𝒶𝒷
+ X
```
### This bounty is on providing even simpler conversion to "state vector" objects without having them wrapped in additional structure.
Libraries like `QuantumOptics.jl`, `QuantumToolbox.jl`, and `qutip` are "just" convenience wrappers around standard vectors and matrices as available in any linear algebra toolkit (julia's LinearAlgebra or python's numpy). Such libraries provide a lot of syntactic sugar and nice utilities, but occasionally one just needs the basic underlying vectors and matrices. Providing this capability is what this bounty is about.
This bounty requires the creation of a new representation type, `StateVectorRepr` under which symbolic objects will be converted to `Vector{ComplexF64}` and `Matrix{ComplexF64}` and comparable sparse matrices. The implementation of this capability can be extremely simple: just use `express(symbolic_object, QuantumOpticsRepr())` and then take the `.data` field of the `QuantumOptics.jl` datastructure. As such, this capability would still depend on `QuantumOptics` internally, but the returned structure would be much simpler.
Basically we get `express(symbolic_object, StateVectorRepr(config)) = express(symbolic_object, QuantumOpticsRepr(config)).data`.
Nonetheless, this needs to be properly packaged and tested.
The most useful references would be:
- [what is the `express` API that is used for conversion from symbolics to numerics](https://doc.quantumsavory.org/QuantumSymbolics.jl/dev/express/)
- [how `express` is implemented for `QuantumOptics`](https://github.com/QuantumSavory/QuantumSymbolics.jl/tree/main/ext/QuantumOpticsExt)
- [the overall documentation of QuantumSymbolics](https://doc.quantumsavory.org/QuantumSymbolics.jl/dev/)
- [conditionally loaded package extensions in julia](https://pkgdocs.julialang.org/v1/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions)) which is how we have structured the dependencies on various external libraries in QuantumSymbolics
For this bounty to be completed, one would need:
- matching the `express` capabilities that exist for `QuantumOptics.jl`, but now simply for conversion to vectors and matrices
- preparing the implementation in the form of a package extension (as is done for QuantumOptics)
- adding tests for correctness, potentially comparing numerical representations against the existing QuantumOptics
- a brief mention of the new backend in the documentation, e.g. towards the bottom of the front page of the docs
If you are new to julia, make sure to:
- install julia using `juliaup` for version management
- look through the [julia manual](https://docs.julialang.org/en/v1/) and [modern workflows](https://modernjuliaworkflows.org/)
- try out VSCode with the [Julia plugin](https://www.julia-vscode.org/) for good IDE support
2 条评论