-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.jl
More file actions
86 lines (70 loc) · 3.3 KB
/
README.jl
File metadata and controls
86 lines (70 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# # QuantumOperatorAlgebra.jl
#
# [](https://ITensor.github.io/QuantumOperatorAlgebra.jl/stable/)
# [](https://ITensor.github.io/QuantumOperatorAlgebra.jl/dev/)
# [](https://github.com/ITensor/QuantumOperatorAlgebra.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [](https://codecov.io/gh/ITensor/QuantumOperatorAlgebra.jl)
# [](https://github.com/invenia/BlueStyle)
# [](https://github.com/JuliaTesting/Aqua.jl)
#
# Quantum operator algebra system. This is mostly meant to be used as a backend in [ITensorMPS.jl](https://github.com/ITensor/ITensorMPS.jl)
# and [ITensorNetworks.jl](https://github.com/ITensor/ITensorNetworks.jl) for lazily representing operator expressions
# that will be turned into quantum circuits and tensor networks.
#
# See also:
# - [ITensorQuantumOperatorDefinitions.jl](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl) for operator definitions
# compatible with this system.
# - [Yao.jl](https://github.com/QuantumBFS/Yao.jl)
# - [Quac.jl](https://github.com/bsc-quantic/Quac.jl)
# - [QuantumAlgebra.jl](https://github.com/jfeist/QuantumAlgebra.jl)
# - [QuantumCumulants.jl](https://github.com/qojulia/QuantumCumulants.jl)
# - [QuantumSymbolics.jl](https://github.com/QuantumSavory/QuantumSymbolics.jl)
# - [QuantumOptics.jl](https://github.com/qojulia/QuantumOptics.jl), [QuantumInterface.jl](https://github.com/qojulia/QuantumInterface.jl)
# - [QuantumLattices.QuantumOperators](https://github.com/Quantum-Many-Body/QuantumLattices.jl/blob/master/src/QuantumOperators.jl)
# ## Installation instructions
# This package resides in the `ITensor/ITensorRegistry` local registry.
# In order to install, simply add that registry through your package manager.
# This step is only required once.
#=
```julia
julia> using Pkg: Pkg
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
```
=#
# or:
#=
```julia
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
```
=#
# if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
# Then, the package can be added as usual through the package manager:
#=
```julia
julia> Pkg.add("QuantumOperatorAlgebra")
```
=#
# ## Examples
using QuantumOperatorAlgebra: Op, Prod, Scaled, Sum, coefficient, sites, terms, which_op
using Test: @test
o1 = Op("X", 1)
o2 = Op("Y", 2)
@test which_op(o1) == "X"
@test sites(o1) == (1,)
o = o1 + o2
@test o isa Sum{Op}
@test terms(o)[1] == o1
@test terms(o)[2] == o2
o *= 2
@test o isa Sum{Scaled{Int,Op}}
@test terms(o)[1] == 2 * o1
@test terms(o)[2] == 2 * o2
@test coefficient(terms(o)[1]) == 2
@test coefficient(terms(o)[2]) == 2
o3 = Op("Z", 3)
o *= o3
@test o isa Sum{Scaled{Int,Prod{Op}}}
@test terms(o)[1] == 2 * o1 * o3
@test terms(o)[2] == 2 * o2 * o3
@test coefficient(terms(o)[1]) == 2
@test coefficient(terms(o)[2]) == 2