A Julia package for working with quantum operators using an algebraic approach. This package provides efficient representations and operations for quantum operators acting on tensor product spaces.
-
Flexible Operator Types: Three main operator types for different use cases:
Op: Single-site operatorsOpChain: Products of operators (non-commutative multiplication)OpSum: Sums of operators (linear combinations)
-
Efficient Representations: Support for both dense and sparse matrices
-
LinearMap Integration: Efficient matrix-free operator representations
-
Linear Algebra Operations: Trace calculations for operators on tensor product spaces
-
ITensor Integration: Automatic conversion to Matrix Product Operators (MPOs) when ITensorMPS.jl is loaded
The package is available through the Julia package manager. You can directly install it from the Julia REPL:
Using the Julia REPL package mode (]):
add OperatorAlgebra
using OperatorAlgebra
using SparseArrays
# Define single-site operators
σx = Op(PAULI_X, 1) # Pauli X on site 1
σz = Op(PAULI_Z, 2) # Pauli Z on site 2
# Create operator products (OpChain)
product = σx * σz
# Create operator sums (OpSum)
hamiltonian = σx + σz + 0.5 * product
# Convert to matrix representation
basis = [1, 2]
H_matrix = sparse(hamiltonian, basis)Compute traces of operators over tensor product spaces:
using LinearAlgebra
# Single operator trace
σz = Op(PAULI_Z, 1)
tr(σz, [1, 2]) # Trace over 2-site system
# Trace of operator products and sums
product = σx * σz
tr(product, [1, 2])
hamiltonian = σx + σz + 0.5 * product
tr(hamiltonian, [1, 2])When ITensorMPS.jl is loaded, operators can be automatically converted to Matrix Product Operators:
using OperatorAlgebra
using ITensorMPS # Extension loads automatically
# Define a spin chain
sites = siteinds("S=1/2", 4)
# Create a Hamiltonian
σx = Op(PAULI_X, 1)
σz = Op(PAULI_Z, 2)
H = σx + σz + 0.5 * (σx * σz)
# Convert to MPO for use with ITensor algorithms
mpo = MPO(H, sites)This is an academic/research project. For questions or suggestions, please contact the author.