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

Functions for applying a tensor product of Pauli operators, as a PauliStr. More...

Functions

void applyControlledPauliStr (Qureg qureg, int control, PauliStr str)
 
void applyMultiControlledPauliStr (Qureg qureg, int *controls, int numControls, PauliStr str)
 
void applyMultiStateControlledPauliStr (Qureg qureg, int *controls, int *states, int numControls, PauliStr str)
 
void applyPauliStr (Qureg qureg, PauliStr str)
 
void multiplyPauliStr (Qureg qureg, PauliStr str)
 

Detailed Description

Functions for applying a tensor product of Pauli operators, as a PauliStr.

Function Documentation

◆ applyControlledPauliStr()

void applyControlledPauliStr ( Qureg qureg,
int control,
PauliStr str )
Note
Documentation for this function or struct is under construction!

Definition at line 784 of file operations.cpp.

784 {
785 validate_quregFields(qureg, __func__);
786 validate_controlAndPauliStrTargets(qureg, control, str, __func__);
787
788 // harmlessly re-validates
789 applyMultiStateControlledPauliStr(qureg, &control, nullptr, 1, str);
790}
void applyMultiStateControlledPauliStr(Qureg qureg, int *controls, int *states, int numControls, PauliStr str)

◆ applyMultiControlledPauliStr()

void applyMultiControlledPauliStr ( Qureg qureg,
int * controls,
int numControls,
PauliStr str )
Note
Documentation for this function or struct is under construction!

Definition at line 792 of file operations.cpp.

792 {
793 validate_quregFields(qureg, __func__);
794 validate_controlsAndPauliStrTargets(qureg, controls, numControls, str, __func__);
795
796 // harmlessly re-validates
797 applyMultiStateControlledPauliStr(qureg, controls, nullptr, numControls, str);
798}

◆ applyMultiStateControlledPauliStr()

void applyMultiStateControlledPauliStr ( Qureg qureg,
int * controls,
int * states,
int numControls,
PauliStr str )
Note
Documentation for this function or struct is under construction!

Definition at line 800 of file operations.cpp.

800 {
801 validate_quregFields(qureg, __func__);
802 validate_controlsAndPauliStrTargets(qureg, controls, numControls, str, __func__);
803 validate_controlStates(states, numControls, __func__); // permits states==nullptr
804
805 qcomp factor = 1;
806 auto ctrlVec = util_getVector(controls, numControls);
807 auto stateVec = util_getVector(states, numControls); // empty if states==nullptr
808
809 // when there are no control qubits, we can merge the density matrix's
810 // operation sinto a single tensor, i.e. +- (shift(str) (x) str), to
811 // avoid superfluous re-enumeration of the state
812 if (qureg.isDensityMatrix && numControls == 0) {
813 factor = paulis_hasOddNumY(str)? -1 : 1;
814 ctrlVec = util_getConcatenated(ctrlVec, util_getBraQubits(ctrlVec, qureg));
815 stateVec = util_getConcatenated(stateVec, stateVec);
816 str = paulis_getKetAndBraPauliStr(str, qureg);
817 }
818
819 localiser_statevec_anyCtrlPauliTensor(qureg, ctrlVec, stateVec, str, factor);
820
821 // but density-matrix control qubits require two distinct operations
822 if (qureg.isDensityMatrix && numControls > 0) {
823 factor = paulis_hasOddNumY(str)? -1 : 1;
824 ctrlVec = util_getBraQubits(ctrlVec, qureg);
825 str = paulis_getShiftedPauliStr(str, qureg.numQubits);
826 localiser_statevec_anyCtrlPauliTensor(qureg, ctrlVec, stateVec, str, factor);
827 }
828}

Referenced by applyControlledPauliStr(), applyMultiControlledPauliStr(), applyMultiStateControlledMultiQubitNot(), applyMultiStateControlledPauliX(), applyMultiStateControlledPauliY(), and applyPauliStr().

◆ applyPauliStr()

void applyPauliStr ( Qureg qureg,
PauliStr str )
Note
Documentation for this function or struct is under construction!

Definition at line 776 of file operations.cpp.

776 {
777 validate_quregFields(qureg, __func__);
778 validate_pauliStrTargets(qureg, str, __func__);
779
780 // harmlessly re-validates
781 applyMultiStateControlledPauliStr(qureg, nullptr, nullptr, 0, str);
782}

◆ multiplyPauliStr()

void multiplyPauliStr ( Qureg qureg,
PauliStr str )
Note
Documentation for this function or struct is under construction!

Definition at line 769 of file operations.cpp.

769 {
770 validate_quregFields(qureg, __func__);
771 validate_pauliStrTargets(qureg, str, __func__);
772
773 localiser_statevec_anyCtrlPauliTensor(qureg, {}, {}, str);
774}

Referenced by multiplyMultiQubitNot().