QuantumCircuits

QuantumCircuits.haar_unitaryMethod
haar_unitary(n::Int) :: Matrix{ComplexF64}

Generate a random Haar unitary matrix of size n x n.

Arguments

  • n::Int: The size of the matrix.

Returns

  • Matrix{ComplexF64}: The generated Haar unitary matrix.
source
QuantumCircuits.random_hermitianMethod
random_hermitian(n::Int) :: Matrix{ComplexF64}

Generate a random Hermitian matrix of size n x n.

Arguments

  • n::Int: The size of the matrix.

Returns

  • Matrix{ComplexF64}: The generated Hermitian matrix.
source
QuantumCircuits.fidelityMethod
fidelity(v1::Vector{ComplexF64}, v2::Vector{ComplexF64}) :: Float64

Compute the fidelity between two complex vectors v1 and v2.

The fidelity is defined as the squared absolute value of the dot product between v1 and v2.

Arguments

  • v1::Vector{ComplexF64}: The first complex vector.
  • v2::Vector{ComplexF64}: The second complex vector.

Returns

  • Float64: The fidelity between v1 and v2.
source
QuantumCircuits.is_valid_statevectorMethod
is_valid_statevector(v::Vector{ComplexF64}) :: Bool

Check if the given vector v is a valid state vector.

A valid state vector is a vector of complex numbers whose Euclidean norm is approximately equal to 1.

Arguments

  • v::Vector{ComplexF64}: The vector to be checked.

Returns

  • true if the vector is a valid state vector, false otherwise.
source
QuantumCircuits.post_measurement_stateMethod
post_measurement_state(state::Vector{ComplexF64}, Π::Matrix{ComplexF64})::Vector{ComplexF64}

Post-processes the state vector after a measurement is performed.

Arguments

  • state::Vector{ComplexF64}: The input state vector.
  • Π::Matrix{ComplexF64}: The measurement operator.

Returns

  • Vector{ComplexF64}: The post-measurement state vector.

Throws

  • ArgumentError: If the probability of getting the measurement outcome is zero.
source
QuantumCircuits.probMethod
prob(state::Vector{ComplexF64}, Π::Matrix{ComplexF64})::Float64

Compute the probability of measuring a quantum state state given the measurement operator Π.

Arguments

  • state::Vector{ComplexF64}: The quantum state vector.
  • Π::Matrix{ComplexF64}: The measurement operator.

Returns

  • Float64: The probability of measuring the state.
source
QuantumCircuits.projective_measurement_operatorMethod
projective_measurement_operator(n::Int, basis::Char, index::Int)::Matrix{ComplexF64}

Constructs the projective measurement operator for a quantum circuit.

Arguments

  • n::Int: The number of qubits in the quantum circuit.
  • basis::Char: The measurement basis. Must be either 'z' or 'x'.
  • index::Int: The index of the qubit to be measured.

Returns

A matrix representing the projective measurement operator.

source
QuantumCircuits.random_statevectorMethod
random_statevector(n::Int) :: Vector{ComplexF64}

Generate a random state vector of length 2^n.

Arguments

  • n::Int: The number of qubits.

Returns

  • v::Vector{ComplexF64}: The random state vector.
source
QuantumCircuits.zero_stateMethod
zero_state(n::Int) :: Vector{ComplexF64}

Initialize the state vector for a quantum circuit with n qubits.

Arguments

  • n::Int: The number of qubits in the quantum circuit.

Returns

  • v::Vector{ComplexF64}: The initialized state vector.
source
QuantumCircuits.unitary_circuit_evolutionMethod
unitary_circuit_evolution(state::Vector{ComplexF64}, no_of_generations)

This function performs the evolution of a quantum state through a unitary circuit.

Arguments

  • state::Vector{ComplexF64}: The initial quantum state represented as a vector of complex numbers.
  • no_of_generations: The number of generations or iterations of the circuit evolution.

Returns

  • final_state::Vector{ComplexF64}: The final quantum state after the specified number of generations.
source
QuantumCircuits.unitary_circuit_evolution_with_measurementMethod
unitary_circuit_evolution_with_measurement(state::Vector{ComplexF64}, no_of_generations)

This function performs the evolution of a quantum circuit with measurements.

Arguments

  • state::Vector{ComplexF64}: The initial state of the quantum circuit.
  • no_of_generations: The number of generations for which the circuit should evolve.

Returns

  • final_state::Vector{ComplexF64}: The final state of the quantum circuit after evolution.

Throws

  • ArgumentError: If the number of qubits is not even or if the number of qubits is less than m.

Description

  • This function evolves a quantum circuit with measurements for a given number of generations.
  • The circuit evolution is performed using unitary matrices generated from the Haar measure.
  • In each generation, the circuit is evolved using either odd or even generation unitary matrices.
  • After each evolution step, a measurement is performed on a randomly chosen qubit using either the $z$ or $x$ basis.
  • The measurement outcome is used to update the state of the circuit.
source