Getting Started

OhMyQSIM is a toy quantum simulator package written in Julia to experiment with different methods and approaches. If you have ideas on how to improve or extend, please get involved. A good place to start is by looking through the issues and adding or trying to address them as appropriate.

Notation

Quantum registers with n-qubits have qubits labeled from 1 to n from left to right as

$| m_1 m_2 m_3 \rangle = |m_1\rangle \otimes |m_2\rangle \otimes |m_3\rangle$

This mens the index of such a state in a state vector is $m_1 2^2 + m_2 2^1 + m_3 2^0$

Basic usage

using OhMyQSIM

# Create a quantum register with 3 qubits and initialise to |000>
qreg = FullStateQuantumRegister{ComplexF64}(3, "000")

# Apply a Pauli x operation to the first qubit 
qreg.apply_1_qubit!(qreg, Gates.x, 1)

# Print the register
println(to_str(qreg))

results in

(1.0 + 0.0im|100>)

Basic functions

OhMyQSIM.binary_reprFunction
binary_repr(num, N)

Get the binary string representation of a decimal integer.

Examples

julia> println(binary_repr(5, 6))
"000101"
source
OhMyQSIM.to_strFunction
to_str(qreg::FullStateQuantumRegister)

Function to convert express fullstate quantum register as a string

Examples

julia> ψ = FullStateQuantumRegister{Int}(3, "000")
julia> ψ.state[end] = 1
julia> to_str(ψ)
"(1|000>) + (1|111>)"
source
OhMyQSIM.apply_2qubit_fullFunction
apply_2qubit_full(qreg, gate, i, j)

Apply the provided 2 qubit gate to qubits i and j by expanding full operator matrix

source
OhMyQSIM.get_confFunction
get_conf(cprobs, num, N)

Given an array of cumulative probabilities of configurations and a random number from [0, 1], return the bitstring it corresponds to

source
OhMyQSIM.measureFunction
measure(qreg, shots)

Given a quantum register, return a typical set of measurements expected

source
OhMyQSIM.get_countsFunction
get_counts(results)

Given a set of measurement results in the form of bitstrings, return the counts of each

source