|
6 | 6 | # [](https://codecov.io/gh/ITensor/QuantumOperatorAlgebra.jl) |
7 | 7 | # [](https://github.com/invenia/BlueStyle) |
8 | 8 | # [](https://github.com/JuliaTesting/Aqua.jl) |
| 9 | +# |
| 10 | +# Quantum operator algebra system. This is mostly meant to be used as a backend in [ITensorMPS.jl](https://github.com/ITensor/ITensorMPS.jl) |
| 11 | +# and [ITensorNetworks.jl](https://github.com/ITensor/ITensorNetworks.jl) for lazily representing operator expressions |
| 12 | +# that will be turned into quantum circuits and tensor networks. |
| 13 | +# |
| 14 | +# See also: |
| 15 | +# - [ITensorQuantumOperatorDefinitions.jl](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl) for operator definitions |
| 16 | +# compatible with this system. |
| 17 | +# - [Yao.jl](https://github.com/QuantumBFS/Yao.jl) |
| 18 | +# - [Quac.jl](https://github.com/bsc-quantic/Quac.jl) |
| 19 | +# - [QuantumAlgebra.jl](https://github.com/jfeist/QuantumAlgebra.jl) |
| 20 | +# - [QuantumCumulants.jl](https://github.com/qojulia/QuantumCumulants.jl) |
| 21 | +# - [QuantumSymbolics.jl](https://github.com/QuantumSavory/QuantumSymbolics.jl) |
| 22 | +# - [QuantumOptics.jl](https://github.com/qojulia/QuantumOptics.jl), [QuantumInterface.jl](https://github.com/qojulia/QuantumInterface.jl) |
| 23 | +# - [QuantumLattices.QuantumOperators](https://github.com/Quantum-Many-Body/QuantumLattices.jl/blob/master/src/QuantumOperators.jl) |
9 | 24 |
|
10 | 25 | # ## Installation instructions |
11 | 26 |
|
@@ -37,5 +52,35 @@ julia> Pkg.add("QuantumOperatorAlgebra") |
37 | 52 |
|
38 | 53 | # ## Examples |
39 | 54 |
|
40 | | -using QuantumOperatorAlgebra: QuantumOperatorAlgebra |
41 | | -# Examples go here. |
| 55 | +using QuantumOperatorAlgebra: Op, Prod, Scaled, Sum, coefficient, sites, terms, which_op |
| 56 | +using Test: @test |
| 57 | + |
| 58 | +o1 = Op("X", 1) |
| 59 | +o2 = Op("Y", 2) |
| 60 | + |
| 61 | +@test which_op(o1) == "X" |
| 62 | +@test sites(o1) == (1,) |
| 63 | + |
| 64 | +o = o1 + o2 |
| 65 | + |
| 66 | +@test o isa Sum{Op} |
| 67 | +@test terms(o)[1] == o1 |
| 68 | +@test terms(o)[2] == o2 |
| 69 | + |
| 70 | +o *= 2 |
| 71 | + |
| 72 | +@test o isa Sum{Scaled{Int,Op}} |
| 73 | +@test terms(o)[1] == 2 * o1 |
| 74 | +@test terms(o)[2] == 2 * o2 |
| 75 | +@test coefficient(terms(o)[1]) == 2 |
| 76 | +@test coefficient(terms(o)[2]) == 2 |
| 77 | + |
| 78 | +o3 = Op("Z", 3) |
| 79 | + |
| 80 | +o *= o3 |
| 81 | + |
| 82 | +@test o isa Sum{Scaled{Int,Prod{Op}}} |
| 83 | +@test terms(o)[1] == 2 * o1 * o3 |
| 84 | +@test terms(o)[2] == 2 * o2 * o3 |
| 85 | +@test coefficient(terms(o)[1]) == 2 |
| 86 | +@test coefficient(terms(o)[2]) == 2 |
0 commit comments