Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 3.34 KB

README.md

File metadata and controls

87 lines (65 loc) · 3.34 KB

QuantumOperatorAlgebra.jl

Stable Dev Build Status Coverage Code Style: Blue Aqua

Quantum operator algebra system. This is mostly meant to be used as a backend in ITensorMPS.jl and ITensorNetworks.jl for lazily representing operator expressions that will be turned into quantum circuits and tensor networks.

See also:

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> using Pkg: Pkg

julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")

or:

julia> Pkg.Registry.add(url="[email protected]: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> 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

This page was generated using Literate.jl.