Crate quest_sys

Source
Expand description

§quest-sys

Rust bindings for the QuEST quantum computer simulator library.

Conforming with the sys crate naming convention this package only provides very thin bindings.

Structs§

Complex
Represents one complex number.
ComplexArray
Represents an array of complex numbers grouped into an array of real components and an array of coressponding complex components.
ComplexMatrix2
Represents a 2x2 matrix of complex numbers.
ComplexMatrix4
Represents a 4x4 matrix of complex numbers
ComplexMatrixN
Represents a general 2^N by 2^N matrix of complex numbers.
DiagonalOp
Represents a diagonal complex operator on the full Hilbert state of a \p Qureg. The operator need not be unitary nor Hermitian (which would constrain it to real values)
PauliHamil
A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represent any Hermitian operator.
QASMLogger
A logger of QASM instructions
QuESTEnv
Information about the environment the program is running in. In practice, this holds info about MPI ranks and helps to hide MPI initialization code
Qureg
Represents a system of qubits. Qubits are zero-based
SubDiagonalOp
Represents a diagonal complex operator of a smaller dimension than the full Hilbert state of a \p Qureg.
Vector
Represents a 3-vector of real numbers

Constants§

bitEncoding_TWOS_COMPLEMENT
bitEncoding_UNSIGNED
pauliOpType_PAULI_I
pauliOpType_PAULI_X
pauliOpType_PAULI_Y
pauliOpType_PAULI_Z
phaseFunc_DISTANCE
phaseFunc_INVERSE_DISTANCE
phaseFunc_INVERSE_NORM
phaseFunc_INVERSE_PRODUCT
phaseFunc_NORM
phaseFunc_PRODUCT
phaseFunc_SCALED_DISTANCE
phaseFunc_SCALED_INVERSE_DISTANCE
phaseFunc_SCALED_INVERSE_NORM
phaseFunc_SCALED_INVERSE_PRODUCT
phaseFunc_SCALED_INVERSE_SHIFTED_DISTANCE
phaseFunc_SCALED_INVERSE_SHIFTED_NORM
phaseFunc_SCALED_INVERSE_SHIFTED_WEIGHTED_DISTANCE
phaseFunc_SCALED_NORM
phaseFunc_SCALED_PRODUCT

Functions§

applyDiagonalOp
Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire \p qureg.
applyFullQFT
Applies the quantum Fourier transform (QFT) to the entirety of \p qureg. The effected unitary circuit (shown here for 4 qubits, bottom qubit is 0) resembles @htmlonly
applyGateMatrixN
Apply a gate specified by a general N-by-N matrix, which may be non-unitary, on any number of target qubits. This function applies the given matrix to both statevector and density matrices as if it were a valid unitary gate. Hence this function is equivalent to multiQubitUnitary(), albeit the unitarity of \p u is not checked nor enforced. This function differs from applyMatrixN() on density matrices.
applyGateSubDiagonalOp
Apply a many-qubit unitary specified as a diagonal matrix upon a specific set of qubits of a quantum register.
applyMatrix2
Apply a general 2-by-2 matrix, which may be non-unitary. The matrix is left-multiplied onto the state, for both state-vectors and density matrices.
applyMatrix4
Apply a general 4-by-4 matrix, which may be non-unitary. The matrix is left-multiplied onto the state, for both state-vectors and density matrices.
applyMatrixN
Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits. The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Note this differs from the action of multiQubitUnitary() on a density matrix.
applyMultiControlledGateMatrixN
Apply a general multi-controlled multi-qubit gate specified as an (possibly non-unitary) arbitrary complex matrix. This is equivalent to multiControlledMultiQubitUnitary() but does not check nor enforce unitary of the given matrix \p m. This differs from applyMultiControlledMatrixN(), because the latter only left-applies the matrix upon density matrices.
applyMultiControlledMatrixN
Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits. The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Hence, this function differs from multiControlledMultiQubitUnitary() by more than just permitting a non-unitary matrix.
applyMultiVarPhaseFunc
Induces a phase change upon each amplitude of \p qureg, determined by a multi-variable exponential polynomial “phase function”.
applyMultiVarPhaseFuncOverrides
Induces a phase change upon each amplitude of \p qureg, determined by a multi-variable exponential polynomial “phase function”, and an explicit set of ‘overriding’ values at specific state indices.
applyNamedPhaseFunc
Induces a phase change upon each amplitude of \p qureg, determined by a named (and potentially multi-variable) phase function.
applyNamedPhaseFuncOverrides
Induces a phase change upon each amplitude of \p qureg, determined by a named (and potentially multi-variable) phase function, and an explicit set of ‘overriding’ values at specific state indices.
applyParamNamedPhaseFunc
Induces a phase change upon each amplitude of \p qureg, determined by a named, paramaterized (and potentially multi-variable) phase function.
applyParamNamedPhaseFuncOverrides
Induces a phase change upon each amplitude of \p qureg, determined by a named, parameterised (and potentially multi-variable) phase function, and an explicit set of ‘overriding’ values at specific state indices.
applyPauliHamil
Modifies \p outQureg to be the result of applying \p PauliHamil (a Hermitian but not necessarily unitary operator) to \p inQureg. Note that afterward, \p outQureg may no longer be normalised and ergo not a state-vector or density matrix. Users must therefore be careful passing \p outQureg to other QuEST functions which assume normalisation in order to function correctly.
applyPauliSum
Modifies \p outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but not necessarily unitary operator) to \p inQureg. Note that afterward, \p outQureg may no longer be normalised and ergo not a state-vector or density matrix. Users must therefore be careful passing \p outQureg to other QuEST functions which assume normalisation in order to function correctly.
applyPhaseFunc
Induces a phase change upon each amplitude of \p qureg, determined by the passed exponential polynomial “phase function”. This effects a diagonal unitary of unit complex scalars, targeting the nominated \p qubits.
applyPhaseFuncOverrides
Induces a phase change upon each amplitude of \p qureg, determined by the passed exponential polynomial “phase function”, and an explicit set of ‘overriding’ values at specific state indices.
applyProjector
Force the target \p qubit of \p qureg into the given classical \p outcome, via a non-renormalising projection.
applyQFT
Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register \p qureg.
applySubDiagonalOp
Left-apply a many-qubit a diagonal matrix upon a specific set of qubits of a quantum register.
applyTrotterCircuit
Applies a trotterisation of unitary evolution \f$ \exp(-i , \text{hamil} , \text{time}) \f$ to \p qureg. This is a sequence of unitary operators, effected by multiRotatePauli(), which together approximate the action of full unitary-time evolution under the given Hamiltonian.
calcDensityInnerProduct
Computes the Hilbert-Schmidt scalar product (which is equivalent to the Frobenius inner product of matrices) of two density matrices \p rho1 and \p rho2 of equivalent size. That is, we define the Hilbert-Schmidt scalar product \f[ ((\rho_1, \rho_2)){HS} := \text{Tr}[ \rho_1^\dagger \rho_2 ], \f] which is equivalent to the sum of products of matrix elemets, i.e., \f[ ((\rho_1, \rho_2)){HS} = \sum\limits_i \sum\limits_j (\rho_1){ij}^* (\rho_2){ij} \f] Assuming that both density matrices are Hermitian, the resulting scalar product is real and invariant under reordering its arguments as \f[ ((\rho_1, \rho_2)){HS} = ((\rho_2, \rho_1)){HS} = \text{Tr}[\rho_1 \rho_2] \f] If both \p rho1 and \p rho2 are density matrices of pure states \p bra and \p ket, then the equality holds \f[ ((\rho_1, \rho_2)){HS} = |\langle \text{bra} | \text{ket} \rangle|^2. \f] If either or both of \p rho1 and \p rho2 are non Hermitian (i.e. invalid density matrices), then this function returns the real component of the scalar product, and discards the imaginary component. That is, it returns \f[ \text{Re}{ \text{Tr}[ \rho_1^\dagger \rho_2 ] } = \text{Re}{ \text{Tr}[ \rho_2^\dagger \rho_1 ] }. \f] This is still sometimes useful, e.g. in calculating the inner product with an anti-commutator, e.g. (for Hermitian \f$ \sigma \f$, \f$ \rho \f$, \f$ H \f$) \f[ ((\sigma, H \rho + \rho H)){HS} = 2 ; \text{Re} { ((\sigma, H \rho))_{HS} } \f] where \f$ H \rho \f$ could be a weighted sum of Pauli products applied to \f$ \rho \f$ through applyPauliSum().
calcExpecDiagonalOp
Computes the expected value of the diagonal operator \p op for state \p qureg. Since \p op is not necessarily Hermitian, the expected value may be a complex number.
calcExpecPauliHamil
Computes the expected value of \p qureg under Hermitian operator \p hamil. Represent \p hamil as \f$ H = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} \f$ (where \f$ c_i \in \f$ \p hamil.termCoeffs and \f$ N = \f$ \p hamil.numQubits). This function computes \f$ \langle \psi | H | \psi \rangle \f$ if \p qureg = \f$ \psi \f$ is a state-vector, and computes \f$ \text{Trace}(H \rho) =\text{Trace}(\rho H) \f$ if \p qureg = \f$ \rho \f$ is a density matrix.
calcExpecPauliProd
Computes the expected value of a product of Pauli operators. Letting \f$ \sigma = \otimes_j \hat{\sigma}_j \f$ be the operators indicated by \p pauliCodes and acting on qubits \p targetQubits, this function computes \f$ \langle \psi | \sigma | \psi \rangle \f$ if \p qureg = \f$ \psi \f$ is a state-vector, and computes \f$ \text{Trace}(\sigma \rho) \f$ if \p qureg = \f$ \rho \f$ is a density matrix.
calcExpecPauliSum
Computes the expected value of a sum of products of Pauli operators. Let \f$ H = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} \f$ be the operators indicated by \p allPauliCodes (where \f$ c_i \in \f$ \p termCoeffs and \f$ N = \f$ \p qureg.numQubitsRepresented). This function computes \f$ \langle \psi | H | \psi \rangle \f$ if \p qureg = \f$ \psi \f$ is a state-vector, and computes \f$ \text{Trace}(H \rho) =\text{Trace}(\rho H) \f$ if \p qureg = \f$ \rho \f$ is a density matrix.
calcFidelity
Calculates the fidelity of \p qureg (a state-vector or density matrix) against a reference pure state (necessarily a state-vector). If \p qureg is a state-vector, this function computes \f[ |\langle \text{qureg} | \text{pureState} \rangle|^2 \f] If \p qureg is a density matrix, this function computes \f[ \langle \text{pureState} | \text{qureg} | \text{pureState} \rangle \f] In either case, the returned fidelity lies in [0, 1] (assuming both input states have valid normalisation). If any of the input \p Quregs are not normalised, this function will return the real component of the correct linear algebra calculation.
calcHilbertSchmidtDistance
Computes the Hilbert Schmidt distance between two density matrices \p a and \p b, defined as the Frobenius norm of the difference between them. That is, we define the Hilbert Schmidt distance \f[ D(a, b) = | a - b |F = \sqrt{ \text{Tr}[ (a-b)(a-b)^\dagger ] } \f] This is equivalent to the square-root of the sum of the absolute value squared of the element-differences of the matrices, i.e. \f[ D(a, b) = \sqrt{ \sum\limits_i \sum\limits_j | a{ij} - b_{ij} |^2 } \f] We caution this may differ by some definitions of the Hilbert Schmidt distance by a square-root.
calcInnerProduct
Computes the inner product \f$ \langle \text{bra} | \text{ket} \rangle \f$ of two equal-size state vectors, given by \f[ \langle \text{bra} | \text{ket} \rangle = \sum_i {\text{bra}_i}^* ; \times ; \text{ket}_i \f] The same \p qureg may be passed as both \p bra and \p ket, though we recommend users check state-vector normalisation with \p calcTotalProb which employs Kahan summation for greater accuracy. Neither state-vector is modified.
calcProbOfAllOutcomes
Populates \p outcomeProbs with the probabilities of every outcome of the sub-register contained in \p qubits.
calcProbOfOutcome
Gives the probability of a specified qubit being measured in the given outcome (0 or 1). This performs no actual measurement and does not change the state of the qubits.
calcPurity
Calculates the purity of a density matrix, by the trace of the density matrix squared. Returns \f$\text{Tr}(\rho^2)\f$. For a pure state, this =1. For a mixed state, the purity is less than 1 and is lower bounded by 1/2^n, where n is the number of qubits. The minimum purity is achieved for the maximally mixed state identity/2^n.
calcTotalProb
A debugging function which calculates the probability of the qubits in \p qureg being in any state, which should always be 1 for correctly normalised states (hence returning a real number). For state-vectors \f$ \psi \f$, this is the norm of the entire state-vector (the sum of the absolute-value-squared of every amplitude): \f[ \sum\limits_i |\psi_i|^2 \f] and for density matrices \f$ \rho \f$, it is the trace: \f[ \text{Trace}(\rho) = \sum\limits_i \rho_{i,i} ; \f]
cloneQureg
Overwrite the amplitudes of \p targetQureg with those from \p copyQureg.
compactUnitary
Apply a single-qubit unitary parameterised by two given complex scalars. Given valid complex numbers \f$\alpha\f$ and \f$\beta\f$, applies the unitary \f[ U = \begin{pmatrix} \alpha & -\beta^* \ \beta & \alpha^* \end{pmatrix} \f] which is general up to a global phase factor. Valid \f$\alpha\f$, \f$\beta\f$ satisfy \f$|\alpha|^2 + |\beta|^2 = 1\f$.
controlledCompactUnitary
Apply a controlled unitary (single control, single target) parameterised by two given complex scalars. Given valid complex numbers \f$\alpha\f$ and \f$\beta\f$, applies the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & \alpha & -\beta^* \ & & \beta & \alpha^* \end{pmatrix} \f] to the control and target qubits. Valid \f$\alpha\f$, \f$\beta\f$ satisfy \f$|\alpha|^2 + |\beta|^2 = 1\f$. The target unitary is general up to a global phase factor.
controlledMultiQubitUnitary
Apply a general controlled multi-qubit unitary (including a global phase factor). One control and any number of target qubits can be specified. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & 1 \ & & & 1 \ & & & & u_{00} & u_{01} & \dots \ & & & & u_{10} & u_{11} & \dots \ & & & & \vdots & \vdots & \ddots \end{pmatrix} \f] on the control and target qubits.
controlledNot
Apply the controlled not (single control, single target) gate, also known as the c-X, c-sigma-X, c-Pauli-X and c-bit-flip gate. This applies pauliX to the target qubit if the control qubit has value 1. This effects the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & & 1 \ & & 1 \end{pmatrix} \f] on the control and target qubits.
controlledPauliY
Apply the controlled pauliY (single control, single target) gate, also known as the c-Y and c-sigma-Y gate. This applies pauliY to the target qubit if the control qubit has value 1. This effects the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & & -i \ & & i \end{pmatrix} \f] on the control and target qubits.
controlledPhaseFlip
Apply the (two-qubit) controlled phase flip gate, also known as the controlled pauliZ gate. For each state, if both input qubits have value one, multiply the amplitude of that state by -1. This applies the two-qubit unitary: \f[ \begin{pmatrix} 1 \ & 1 \
& & 1 \ & & & -1 \end{pmatrix} \f] with circuit diagram: @htmlonly
controlledPhaseShift
Introduce a phase factor \f$ \exp(i \theta) \f$ on state \f$ |11\rangle \f$ of qubits \p idQubit1 and \p idQubit2. For angle \f$\theta\f$, this effects the unitary \f[ \begin{pmatrix} 1 & & & \ & 1 & & \ & & 1 & \ & & & \exp(i \theta) \end{pmatrix} \f] on \p idQubit1 and \p idQubit2.
controlledRotateAroundAxis
Applies a controlled rotation by a given angle around a given vector on the Bloch-sphere. The vector must not be zero (else an error is thrown), but needn’t be unit magnitude.
controlledRotateX
Applies a controlled rotation by a given angle around the X-axis of the Bloch-sphere. The target qubit is rotated in states where the control qubit has value 1.
controlledRotateY
Applies a controlled rotation by a given angle around the Y-axis of the Bloch-sphere. The target qubit is rotated in states where the control qubit has value 1.
controlledRotateZ
Applies a controlled rotation by a given angle around the Z-axis of the Bloch-sphere. The target qubit is rotated in states where the control qubit has value 1.
controlledTwoQubitUnitary
Apply a general controlled two-qubit unitary (including a global phase factor). The given unitary is applied to the target amplitudes where the control qubit has value 1. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & 1 \ & & & 1 \ & & & & u_{00} & u_{01} & u_{02} & u_{03} \ & & & & u_{10} & u_{11} & u_{12} & u_{13} \ & & & & u_{20} & u_{21} & u_{22} & u_{23} \ & & & & u_{30} & u_{31} & u_{32} & u_{33} \end{pmatrix} \f] on the control and target qubits.
controlledUnitary
Apply a general controlled unitary (single control, single target), which can include a global phase factor. The given unitary is applied to the target qubit if the control qubit has value 1, effecting the two-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \ & & u_{00} & u_{01}\ & & u_{10} & u_{11} \end{pmatrix} \f] on the control and target qubits.
copyStateFromGPU
In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user. In CPU mode, this function has no effect. In conjunction with copyStateToGPU(), this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use setAmps() if possible.
createCloneQureg
Create a new ::Qureg which is an exact clone of the passed qureg, which can be either a state-vector or a density matrix.
createComplexMatrixN
Allocate dynamic memory for a square complex matrix of any size, which can be passed to functions like multiQubitUnitary() and applyMatrixN().
createDensityQureg
Creates a density matrix Qureg object representing a set of qubits which can enter noisy and mixed states.
createDiagonalOp
Creates a ::DiagonalOp representing a diagonal operator on the full Hilbert space of a ::Qureg.
createDiagonalOpFromPauliHamilFile
Creates and initialiases a diagonal operator from the Z Pauli Hamiltonian encoded in file with filename \p fn.
createPauliHamil
Dynamically allocates a Hamiltonian expressed as a real-weighted sum of products of Pauli operators.
createPauliHamilFromFile
Creates a \p PauliHamil instance, a real-weighted sum of products of Pauli operators, populated with the data in filename \p fn.
createQuESTEnv
Create the QuEST execution environment. This should be called only once, and the environment should be freed with destroyQuESTEnv at the end of the user’s code. If something needs to be done to set up the execution environment, such as initializing MPI when running in distributed mode, it is handled here.
createQureg
Creates a state-vector Qureg object representing a set of qubits which will remain in a pure state.
createSubDiagonalOp
Creates a ::SubDiagonalOp representing a diagonal operator which can act upon a subset of the qubits in a ::Qureg. This is similar to a ::DiagonalOp acting upon specific qubits.
destroyComplexMatrixN
Destroy a ComplexMatrixN instance created with createComplexMatrixN()
destroyDiagonalOp
Destroys a ::DiagonalOp created with createDiagonalOp(), freeing its memory.
destroyPauliHamil
Destroy a ::PauliHamil instance, created with either createPauliHamil() or createPauliHamilFromFile().
destroyQuESTEnv
Destroy the QuEST environment. If something needs to be done to clean up the execution environment, such as finalizing MPI when running in distributed mode, it is handled here
destroyQureg
Deallocate a ::Qureg, freeing its memory.
destroySubDiagonalOp
Destroy a ::SubDiagonalOp instance created with createSubDiagonalOp().
getAmp
Get the complex amplitude at a given index in the state vector.
getDensityAmp
Get an amplitude from a density matrix at a given row and column.
getEnvironmentString
Sets \p str to a string containing information about the runtime environment, including whether simulation is using CUDA (for GPU), OpenMP (for multithreading) and/or MPI (for distribution). The number of CPU threads and distributed ranks is also reported. Note there is currently no reporting of the number of GPU cores used.
getImagAmp
Get the imaginary component of the complex probability amplitude at an index in the state vector.
getNumAmps
Returns the number of complex amplitudes in a state-vector \p qureg.
getNumQubits
Returns the number of qubits represented by \p qureg.
getProbAmp
Get the probability of a state-vector at an index in the full state vector.
getQuESTSeeds
Obtain the seeds presently used in random number generation.
getRealAmp
Get the real component of the complex probability amplitude at an index in the state vector.
hadamard
Apply the single-qubit Hadamard gate. This takes \f$|0\rangle\f$ to \f$|+\rangle\f$ and \f$|1\rangle\f$ to \f$|-\rangle\f$, and is equivalent to a rotation of \f$\pi\f$ around the x-axis then \f$\pi/2\f$ about the y-axis on the Bloch-sphere. I.e. \f[ \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \ 1 & -1 \end{pmatrix} \f]
initBlankState
Initialises a qureg to have all-zero-amplitudes. This is an unphysical state useful for iteratively building a state with functions like setWeightedQureg(), and should not be confused with initZeroState().
initClassicalState
Initialise \p qureg into the classical state (also known as a “computational basis state”) with index \p stateInd.
initComplexMatrixN
Initialises a ComplexMatrixN instance to have the passed \p real and \p imag values. This allows succint population of any-sized ComplexMatrixN, e.g. through 2D arrays:
initDebugState
Initialises \p qureg to be in the un-normalised, non-physical state with with \f$n\f$-th complex amplitude given by \f$2n/10 + i(2n+1)/10\f$.
initDiagonalOp
Overwrites the entire ::DiagonalOp \p op with the given \p real and \p imag complex elements.
initDiagonalOpFromPauliHamil
Populates the diagonal operator \p op to be equivalent to the given Pauli Hamiltonian \p hamil, assuming \p hamil contains only PAULI_Z operators.
initPauliHamil
Initialise ::PauliHamil instance \p hamil with the given term coefficients and Pauli codes (one for every qubit in every term).
initPlusState
Initialise \p qureg into the plus state.
initPureState
Initialise \p qureg into to a given pure state of an equivalent Hilbert dimension.
initStateFromAmps
Initialise \p qureg by specifying all amplitudes. For density matrices, it is assumed the amplitudes have been flattened column-wise into the given arrays.
initZeroState
Initialise \p qureg into the zero state.
measure
Measures a single qubit, collapsing it randomly to 0 or 1.
mixDamping
Mixes a density matrix \p qureg to induce single-qubit amplitude damping (decay to 0 state). With probability \p prob, applies damping (transition from 1 to 0 state).
mixDensityMatrix
Modifies combineQureg to become (1-\p prob)\p combineProb + \p prob \p otherQureg. Both registers must be equal-dimension density matrices, and prob must be in [0, 1].
mixDephasing
Mixes a density matrix \p qureg to induce single-qubit dephasing noise. With probability \p prob, applies Pauli Z to \p targetQubit.
mixDepolarising
Mixes a density matrix \p qureg to induce single-qubit homogeneous depolarising noise. This is equivalent to, with probability \p prob, uniformly randomly applying either Pauli X, Y, or Z to \p targetQubit.
mixKrausMap
Apply a general single-qubit Kraus map to a density matrix, as specified by at most four Kraus operators, \f$K_i\f$ (\p ops). A Kraus map is also referred to as a “operator-sum representation” of a quantum channel, and enables the simulation of general single-qubit noise process, by effecting \f[ \rho \to \sum\limits_i^{\text{numOps}} K_i \rho K_i^\dagger \f]
mixMultiQubitKrausMap
Apply a general N-qubit Kraus map to a density matrix, as specified by at most (2N)^2 Kraus operators. This allows one to simulate a general noise process.
mixNonTPKrausMap
Apply a general non-trace-preserving single-qubit Kraus map to a density matrix, as specified by at most four operators, \f$K_i\f$ (\p ops). This effects \f[ \rho \to \sum\limits_i^{\text{numOps}} K_i \rho K_i^\dagger \f] where \f$K_i\f$ are permitted to be any matrix. This means the density matrix can enter a non-physical state.
mixNonTPMultiQubitKrausMap
Apply a general N-qubit non-trace-preserving Kraus map to a density matrix, as specified by at most (2N)^2 operators.
mixNonTPTwoQubitKrausMap
Apply a general non-trace-preserving two-qubit Kraus map to a density matrix, as specified by at most sixteen operators, \f$K_i\f$ (\p ops).
mixPauli
Mixes a density matrix \p qureg to induce general single-qubit Pauli noise. With probabilities \p probX, \p probY and \p probZ, applies Pauli X, Y, and Z respectively to \p targetQubit.
mixTwoQubitDephasing
Mixes a density matrix \p qureg to induce two-qubit dephasing noise. With probability \p prob, applies Pauli Z to either or both qubits.
mixTwoQubitDepolarising
Mixes a density matrix \p qureg to induce two-qubit homogeneous depolarising noise. With probability \p prob, applies to \p qubit1 and \p qubit2 any operator of the set \f${ IX, IY, IZ, XI, YI, ZI, XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ }\f$. Note this is the set of all two-qubit Pauli gates excluding \f$II\f$.
mixTwoQubitKrausMap
Apply a general two-qubit Kraus map to a density matrix, as specified by at most sixteen Kraus operators. A Kraus map is also referred to as a “operator-sum representation” of a quantum channel. This allows one to simulate a general two-qubit noise process.
multiControlledMultiQubitNot
Apply a NOT (or Pauli X) gate with multiple control and target qubits. This applies pauliX to qubits \p targs on every basis state for which the control qubits \p ctrls are all in the \f$|1\rangle\f$ state. The ordering within each of \p ctrls and \p targs has no effect on the operation.
multiControlledMultiQubitUnitary
Apply a general multi-controlled multi-qubit unitary (including a global phase factor). Any number of control and target qubits can be specified. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & u_{00} & u_{01} & \dots \ & & & u_{10} & u_{11} & \dots \ & & & \vdots & \vdots & \ddots \end{pmatrix} \f] on the control and target qubits.
multiControlledMultiRotatePauli
Apply a multi-controlled multi-target multi-Pauli rotation, also known as a controlled Pauli gadget. This is the unitary \f[ |1\rangle\langle 1|^{\otimes, \text{numControls}} ; \otimes , \exp \left( - i , \frac{\theta}{2} ; \bigotimes_{j}^{\text{numTargets}} \hat{\sigma}j\right) ;;+;; \sum\limits{k=0}^{2^{,\text{numControls}} - 2} |k\rangle\langle k| \otimes \text{I} \f] where \f$\hat{\sigma}_j\f$ are the Pauli operators (::pauliOpType) in targetPaulis, which operate upon the corresponding qubits in targetQubits.
multiControlledMultiRotateZ
Apply a multi-controlled multi-target Z rotation, also known as a controlled phase gadget. This is the unitary \f[ |1\rangle\langle 1|^{\otimes, \text{numControls}} ; \otimes , \exp \left( - i , \frac{\theta}{2} ; \bigotimes_{j}^{\text{numTargets}} Z_j\right) ;;+;; \sum\limits_{k=0}^{2^{,\text{numControls}} - 2} |k\rangle\langle k| \otimes \text{I} \f] where the Pauli Z gates operate upon the qubits in targetQubits, and cause rotations of \f$\theta =\f$ \p angle.
multiControlledPhaseFlip
Apply the multiple-qubit controlled phase flip gate, also known as the multiple-qubit controlled pauliZ gate. For each state, if all control qubits have value one, multiply the amplitude of that state by -1. This applies the many-qubit unitary: \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & 1 \ & & & & -1 \end{pmatrix} \f] on the control qubits.
multiControlledPhaseShift
Introduce a phase factor \f$ \exp(i \theta) \f$ on state \f$ |1 \dots 1 \rangle \f$ of the passed qubits.
multiControlledTwoQubitUnitary
Apply a general multi-controlled two-qubit unitary (including a global phase factor). Any number of control qubits can be specified, and if all have value 1, the given unitary is applied to the target qubit. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & u_{00} & u_{01} & u_{02} & u_{03} \ & & & u_{10} & u_{11} & u_{12} & u_{13} \ & & & u_{20} & u_{21} & u_{22} & u_{23} \ & & & u_{30} & u_{31} & u_{32} & u_{33} \end{pmatrix} \f] on the control and target qubits.
multiControlledUnitary
Apply a general multiple-control single-target unitary, which can include a global phase factor. Any number of control qubits can be specified, and if all have value 1, the given unitary is applied to the target qubit. This effects the many-qubit unitary \f[ \begin{pmatrix} 1 \ & 1 \
& & \ddots \ & & & u_{00} & u_{01}\ & & & u_{10} & u_{11} \end{pmatrix} \f] on the control and target qubits. The given 2x2 ComplexMatrix must be unitary, otherwise an error is thrown.
multiQubitUnitary
Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubits.
pauliX
Apply the single-qubit Pauli-X (also known as the X, sigma-X, NOT or bit-flip) gate. This is a rotation of \f$\pi\f$ around the x-axis on the Bloch sphere. I.e. \f[ \begin{pmatrix} 0 & 1 \ 1 & 0 \end{pmatrix} \f] with circuit diagram: @htmlonly
pauliY
Apply the single-qubit Pauli-Y (also known as the Y or sigma-Y) gate. This is a rotation of \f$\pi\f$ around the Y-axis on the Bloch sphere. I.e. \f[ \begin{pmatrix} 0 & -i \ i & 0 \end{pmatrix} \f] with circuit diagram: @htmlonly
pauliZ
Apply the single-qubit Pauli-Z (also known as the Z, sigma-Z or phase-flip) gate. This is a rotation of \f$\pi\f$ around the Z-axis (a phase shift) on the Bloch sphere. I.e. \f[ \begin{pmatrix} 1 & 0 \ 0 & -1 \end{pmatrix} \f] with circuit diagram: @htmlonly
phaseShift
Shift the phase between \f$ |0\rangle \f$ and \f$ |1\rangle \f$ of a single qubit by a given angle.
reportPauliHamil
Print the \p PauliHamil to screen. The output features a new line for each term, each with format
reportQuESTEnv
Report information about the QuEST environment
reportQuregParams
Report metainformation about a set of qubits: number of qubits, number of probability amplitudes.
reportState
Print the current state vector of probability amplitudes for a set of qubits to file. File format: @verbatim real, imag realComponent1, imagComponent1 realComponent2, imagComponent2 … realComponentN, imagComponentN @endverbatim
reportStateToScreen
Print the current state vector of probability amplitudes for a set of qubits to standard out. For debugging purposes. Each rank should print output serially. Only print output for systems <= 5 qubits
rotateAroundAxis
Rotate a single qubit by a given angle around a given \ref Vector on the Bloch-sphere. The vector must not be zero (else an error is thrown), but needn’t be unit magnitude, since it will be normalised by QuEST.
rotateX
Rotate a single qubit by a given angle around the X-axis of the Bloch-sphere. For angle \f$\theta\f$, applies \f[ \begin{pmatrix} \cos\theta/2 & -i \sin \theta/2\ -i \sin \theta/2 & \cos \theta/2 \end{pmatrix} \f] with circuit diagram: @htmlonly
rotateY
Rotate a single qubit by a given angle around the Y-axis of the Bloch-sphere. For angle \f$\theta\f$, applies \f[ \begin{pmatrix} \cos\theta/2 & - \sin \theta/2\ \sin \theta/2 & \cos \theta/2 \end{pmatrix} \f] with circuit diagram: @htmlonly
rotateZ
Rotate a single qubit by a given angle around the Z-axis of the Bloch-sphere (also known as a phase shift gate). For angle \f$\theta\f$, applies \f[ \begin{pmatrix} \exp(-i \theta/2) & 0 \ 0 & \exp(i \theta/2) \end{pmatrix} \f] with circuit diagram: @htmlonly
sGate
Apply the single-qubit S gate. This is a rotation of \f$\pi/2\f$ around the Z-axis on the Bloch sphere, or the unitary: \f[ \begin{pmatrix} 1 & 0 \ 0 & i \end{pmatrix} \f] with circuit diagram: @htmlonly
seedQuEST
Seeds the random number generator with a custom array of key(s), overriding the default keys.
setAmps
Overwrites a contiguous subset of the amplitudes in state-vector \p qureg, with those passed in \p reals and \p imags.
setDensityAmps
Overwrites a contiguous subset of the amplitudes in density-matrix \p qureg, with those passed in \p reals and \p imags, intrepreted column-wise.
setDiagonalOpElems
Modifies a subset (starting at index \p startInd, and ending at index \p startInd + \p numElems) of the elements in ::DiagonalOp \p op with the given complex numbers (passed as \p real and \p imag components).
setQuregToPauliHamil
Overwrites the density-matrix \p qureg with the Z-basis matrix representation of the given real-weighted sum of Pauli tensors \p hamil.
setWeightedQureg
Modifies qureg \p out to the result of (\p facOut \p out + \p fac1 \p qureg1 + \p fac2 \p qureg2), imposing no constraints on normalisation. Works for both state-vectors and density matrices. Note that afterward, \p out may not longer be normalised and ergo no longer a valid state-vector or density matrix. Users must therefore be careful passing \p out to other QuEST functions which assume normalisation in order to function correctly.
statevec_twoQubitUnitary
swapGate
Performs a SWAP gate between \p qubit1 and \p qubit2. This effects \f[ \begin{pmatrix} 1 \ & & 1 \
& 1 \ & & & 1 \end{pmatrix} \f] on the designated qubits, though is performed internally by three CNOT gates.
tGate
Apply the single-qubit T gate. This is a rotation of \f$\pi/4\f$ around the Z-axis on the Bloch sphere, or the unitary: \f[ \begin{pmatrix} 1 & 0 \ 0 & \exp\left(i \frac{\pi}{4}\right) \end{pmatrix} \f] with circuit diagram: @htmlonly
twoQubitUnitary
Apply a general two-qubit unitary (including a global phase factor).
unitary
Apply a general single-qubit unitary (including a global phase factor). The passed 2x2 ComplexMatrix must be unitary, otherwise an error is thrown.

Type Aliases§

bitEncoding
Flags for specifying how the bits in sub-register computational basis states are mapped to indices in functions like applyPhaseFunc().
pauliOpType
Codes for specifying Pauli operators
phaseFunc
Flags for specifying named phase functions. These can be passed to functions applyNamedPhaseFunc(), applyNamedPhaseFuncOverrides(), applyParamNamedPhaseFunc(), and applyParamNamedPhaseFuncOverrides().