The Quantum Exact Simulation Toolkit v4.2.0
Loading...
Searching...
No Matches

Functions for pre- or post-multiplying general one-qubit dense matrices (as CompMatr1) upon density matrices. More...

Functions

void leftapplyCompMatr1 (Qureg qureg, int target, CompMatr1 matrix)
 
void rightapplyCompMatr1 (Qureg qureg, int target, CompMatr1 matrix)
 

Detailed Description

Functions for pre- or post-multiplying general one-qubit dense matrices (as CompMatr1) upon density matrices.

Function Documentation

◆ leftapplyCompMatr1()

void leftapplyCompMatr1 ( Qureg qureg,
int target,
CompMatr1 matrix )

Multiplies a general one-qubit dense matrix upon the specified target qubit of qureg.

Formulae
Let \( \hat{M} = \) matrix and \( t = \) target, and notate \(\hat{M}_t\) as per applyCompMatr1(). Unlike applyCompMatr1() however, this function only ever left-multiplies matrix upon qureg, regardless of whether it is a statevector or density matrix.

Explicitly,

  • When qureg is a statevector \( \svpsi \), this function effects

    \[ \svpsi \rightarrow \hat{M}_t \, \svpsi. \]

  • When qureg is a density matrix \(\dmrho\), this function effects

    \[ \dmrho \rightarrow \hat{M}_t \, \dmrho. \]

There are no additional constraints like unitarity.

Example
{0.1, 0.2},
{0.3i, 0.4i}
});
leftapplyCompMatr1(qureg, 2, matrix);
CompMatr1 getInlineCompMatr1({{ matrix }})
void leftapplyCompMatr1(Qureg qureg, int target, CompMatr1 matrix)
Qureg createDensityQureg(int numQubits)
Definition qureg.cpp:291
Definition qureg.h:49
Parameters
[in,out]quregthe state to modify.
[in]targetthe index of the target qubit.
[in]matrixthe Z-basis matrix to multiply upon the left.
Exceptions
error
  • if qureg or matrix are uninitialised.
  • if target is an invalid qubit index.
See also
Author
Tyson Jones

Definition at line 31 of file multiplication.cpp.

31 {
32 validate_quregFields(qureg, __func__);
33 validate_target(qureg, target, __func__);
34 validate_matrixFields(matrix, __func__);
35
36 bool conj = false;
37 bool transp = false;
38 localiser_statevec_anyCtrlOneTargDenseMatr(qureg, {}, {}, target, matrix, conj, transp);
39}

◆ rightapplyCompMatr1()

void rightapplyCompMatr1 ( Qureg qureg,
int target,
CompMatr1 matrix )

Multiplies a general one-qubit dense matrix upon the specified target qubit of the density matrix qureg, from the right-hand side.

Formulae
Let \( \dmrho = \) qureg, \( \hat{M} = \) matrix and \( t = \) target, and notate \(\hat{M}_t\) as per applyCompMatr1(). Unlike applyCompMatr1() however, this function only ever right-multiplies matrix upon qureg.

Explicitly

\[ \dmrho \rightarrow \dmrho \, \hat{M}_t \]

where \( \hat{M} \) is not conjugated nor transposed, and there are no additional constraints like unitarity.

In general, this function will break the normalisation of qureg and result in a non-physical state, and is useful for preparing sub-expressions of formulae like the Linbladian.

Example
{0.1, 0.2},
{0.3i, 0.4i}
});
rightapplyCompMatr1(qureg, 2, matrix);
void rightapplyCompMatr1(Qureg qureg, int target, CompMatr1 matrix)
Parameters
[in,out]quregthe state to modify.
[in]targetthe index of the target qubit.
[in]matrixthe Z-basis matrix to post-multiply.
Exceptions
error
  • if qureg or matrix are uninitialised.
  • if qureg is not a density matrix.
  • if target is an invalid qubit index.
See also
Author
Tyson Jones

Definition at line 41 of file multiplication.cpp.

41 {
42 validate_quregFields(qureg, __func__);
43 validate_quregIsDensityMatrix(qureg, __func__);
44 validate_target(qureg, target, __func__);
45 validate_matrixFields(matrix, __func__);
46
47 // rho matrix ~ transpose(rho) (x) I ||rho>>
48 bool conj = false;
49 bool transp = true;
50 int qubit = util_getBraQubit(target, qureg);
51 localiser_statevec_anyCtrlOneTargDenseMatr(qureg, {}, {}, qubit, matrix, conj, transp);
52}