Skip to content

Commit 6be1dac

Browse files
authored
Initial implementation (#1)
1 parent 81b5e60 commit 6be1dac

File tree

8 files changed

+934
-6
lines changed

8 files changed

+934
-6
lines changed

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
99

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)
24+
1025
## Installation instructions
1126

1227
This package resides in the `ITensor/ITensorRegistry` local registry.
@@ -32,10 +47,39 @@ julia> Pkg.add("QuantumOperatorAlgebra")
3247
## Examples
3348

3449
````julia
35-
using QuantumOperatorAlgebra: QuantumOperatorAlgebra
36-
````
50+
using QuantumOperatorAlgebra: Op, Prod, Scaled, Sum, coefficient, sites, terms, which_op
51+
using Test: @test
52+
53+
o1 = Op("X", 1)
54+
o2 = Op("Y", 2)
55+
56+
@test which_op(o1) == "X"
57+
@test sites(o1) == (1,)
58+
59+
o = o1 + o2
3760

38-
Examples go here.
61+
@test o isa Sum{Op}
62+
@test terms(o)[1] == o1
63+
@test terms(o)[2] == o2
64+
65+
o *= 2
66+
67+
@test o isa Sum{Scaled{Int,Op}}
68+
@test terms(o)[1] == 2 * o1
69+
@test terms(o)[2] == 2 * o2
70+
@test coefficient(terms(o)[1]) == 2
71+
@test coefficient(terms(o)[2]) == 2
72+
73+
o3 = Op("Z", 3)
74+
75+
o *= o3
76+
77+
@test o isa Sum{Scaled{Int,Prod{Op}}}
78+
@test terms(o)[1] == 2 * o1 * o3
79+
@test terms(o)[2] == 2 * o2 * o3
80+
@test coefficient(terms(o)[1]) == 2
81+
@test coefficient(terms(o)[2]) == 2
82+
````
3983

4084
---
4185

examples/README.jl

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
# [![Coverage](https://codecov.io/gh/ITensor/QuantumOperatorAlgebra.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/QuantumOperatorAlgebra.jl)
77
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](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)
924

1025
# ## Installation instructions
1126

@@ -37,5 +52,35 @@ julia> Pkg.add("QuantumOperatorAlgebra")
3752

3853
# ## Examples
3954

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

Comments
 (0)