Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](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.
Expand All @@ -32,10 +47,39 @@ julia> Pkg.add("QuantumOperatorAlgebra")
## Examples

````julia
using QuantumOperatorAlgebra: QuantumOperatorAlgebra
````
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

Examples go here.
@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
````

---

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

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

# ## Examples

using QuantumOperatorAlgebra: QuantumOperatorAlgebra
# Examples go here.
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
Loading
Loading