Utils

Utilities to create and destroy environment etc.

pyquest_cffi.utils.dataoperation Manage QuEST environments and quantum registers
pyquest_cffi.utils.reporting Reporting of QuEST states

Dataoperation

Manage QuEST environments and quantum registers

class pyquest_cffi.utils.dataoperation.cloneQureg(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Clone a qureg state into another one

Set qureg_clone to be a clone of qureg_original

Parameters:
  • qureg_original – Qureg to be cloned
  • qureg_clone – Cloned qureg
call_interactive(qureg_clone: Qureg, qureg_original: Qureg) → None[source]

Interactive call of PyQuest-cffi

Parameters:
  • qureg_original – Qureg to be cloned
  • qureg_clone – Cloned qureg
Raises:
  • TypeError – The quregs need to be of the same type, so either both density matrices OR both wave functions
  • ValueError – The quregs need to contain the same number of qubits
class pyquest_cffi.utils.dataoperation.createCloneQureg(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Create a clone of the qureg in a certain environment

Parameters:
  • qureg – Qureg to be cloned
  • env – QuEST environment the clone is created in
call_interactive(qureg: Qureg, env: QuESTEnv) → Qureg[source]

Interactive call of PyQuest-cffi

Parameters:
  • qureg – Qureg to be cloned
  • env – QuEST environment the clone is created in
Returns:

cloned qureg

Return type:

tqureg

class pyquest_cffi.utils.dataoperation.createDensityQureg(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Allocate memory for a density matrix quantum/qubit register (qureg)

Parameters:
  • num_qubits – number of qubits in the quantum register
  • env – QuEST environment in which the qureg exists
call_interactive(num_qubits: int, env: QuESTEnv) → Qureg[source]

Interactive call of PyQuest-cffi

Parameters:
  • num_qubits – number of qubits in the quantum register
  • env – QuEST environment in which the qureg exists
Returns:

tqureg

class pyquest_cffi.utils.dataoperation.createPauliHamil(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Create a Hamiltonian expressed as a real-weighted sum of products of Pauli operators

Parameters:
  • number_qubits – the number of qubits on which this Hamiltonian acts
  • number_pauliprods – the number of weighted terms in the sum, or the number of Pauli products
call_interactive(number_qubits: int, number_pauliprods: int) → <sphinx.ext.autodoc.importer._MockObject object at 0x7f319bfc4828>[source]

Interactive call of PyQuest-cffi

Parameters:
  • number_qubits – the number of qubits on which this Hamiltonian acts
  • number_pauliprods – the number of weighted terms in the sum/number of Pauli products
Returns:

created Pauli Hamiltonian

Return type:

PauliHamil

Raises:

RuntimeError – number_qubits and number_pauliprods need to be positive integers

class pyquest_cffi.utils.dataoperation.createQuestEnv(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Creates the QuEST simulator environment, needed for all simulations

call_interactive() → QuESTEnv[source]

Interactive call of PyQuest-cffi

Returns:tquestenv
class pyquest_cffi.utils.dataoperation.createQureg(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Allocate memory for a wavefunction quantum/qubit register (qureg)

Parameters:
  • num_qubits – number of qubits in the quantum register
  • env – QuEST environment in which the qureg exists
call_interactive(num_qubits: int, env: QuESTEnv) → Qureg[source]

Interactive call of PyQuest-cffi

Parameters:
  • num_qubits – number of qubits in the quantum register
  • env – QuEST environment in which the qureg exists
Returns:

tqureg

class pyquest_cffi.utils.dataoperation.destroyPauliHamil(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Destroy a PauliHamil instance

Parameters:pauli_hamil – PauliHamil to be destroyed
call_interactive(pauli_hamil: PauliHamil) → None[source]

Interactive call of PyQuest-cffi

Parameters:pauli_hamil – PauliHamil to be destroyed
class pyquest_cffi.utils.dataoperation.destroyQuestEnv(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Deallocate QuEST simulation environment

Parameters:env – QuEST environment to be deallocated
call_interactive(env: QuESTEnv) → None[source]

Interactive call of PyQuest-cffi

Parameters:env – QuEST environment to be deallocated
class pyquest_cffi.utils.dataoperation.destroyQureg(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Deallocate memory for a quantum/qubit register

Parameters:
  • qubits – Qubits in system
  • env – QuEST environment in which the qureg exists
call_interactive(qubits: List[int], env: QuESTEnv) → None[source]

Interactive call of PyQuest-cffi

Parameters:
  • qubits – Qubits in system
  • env – QuEST environment in which the qureg exists

Reporting

Reporting of QuEST states

class pyquest_cffi.utils.reporting.reportPauliHamil(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Report PauliHamil to stdout

The output features a new line for each term, each with format: “c p1 p2 p3 … pN”, where c is the real coefficient of the term, and p1 … pN are numbers 0, 1, 2, 3 to indicate identity, pauliX, pauliY and pauliZ operators respectively, acting on qubits 0 through N-1 (all qubits). A tab character separates c and p1, single spaces separate the Pauli operators

Parameters:pauli_hamil – instatiated PauliHamil
argtype

Return argument type

Returns:List[str]
call_interactive(pauli_hamil: PauliHamil) → None[source]

Interactive call of PyQuest-cffi

Parameters:pauli_hamil – instatiated PauliHamil
restype

Return result type

Returns:str
class pyquest_cffi.utils.reporting.reportQuESTEnv(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Report the properties of the QuEST simulation environment to stdout

Parameters:env – QuEST environment for which the parameter are reported
argtype

Return type of argument

Returns:List[str]
call_interactive(env: QuESTEnv) → None[source]

Interactive call of PyQuest-cffi

Parameters:env – QuEST environment for which the parameter are reported
restype

Return result type

Returns:str
class pyquest_cffi.utils.reporting.reportQuregParams(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Reports the parameters of a quantum register to stdout

Parameters:qureg – Quantum register for which the parameter are reported
argtype

Return argument type

Returns:List[str]
call_interactive(qureg: Qureg) → None[source]

Interactive call of PyQuest-cffi

Parameters:qureg – Quantum register for which the parameter are reported
restype

Return result type

Returns:str
class pyquest_cffi.utils.reporting.reportState(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Report QuEST state

Parameters:qureg – Quantum Register (qureg)
argtype

Return argument type

Returns:List[str]
call_interactive(qureg: Qureg) → None[source]

Interactive call of PyQuest-cffi

Parameters:qureg – Quantum Register (qureg)
restype

Return result type

Returns:str
class pyquest_cffi.utils.reporting.reportStateToScreen(interactive: bool = True)[source]

Bases: pyquest_cffi.questlib._abstract._PYQUEST

Report statevector or density matrix in a qureg to stdout

Parameters:
  • qureg – the quantum register
  • env – the environment of the quantum register
argtype

Return argument type

Returns:List[str]
call_interactive(qureg: Qureg, env: QuESTEnv, a: int = 0) → None[source]

Interactive call of PyQuest-cffi

Parameters:
  • qureg – the quantum register
  • env – the environment of the quantum register
  • a – integer
restype

Return result type

Returns:str