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

Functions for applying, exponentiating or Trotterising a weigthed sum of Pauli tensors. More...

Functions

void applyTrotterizedPauliStrSumGadget (Qureg qureg, PauliStrSum sum, qreal angle, int order, int reps)
 
void multiplyPauliStrSum (Qureg qureg, PauliStrSum sum, Qureg workspace)
 

Detailed Description

Functions for applying, exponentiating or Trotterising a weigthed sum of Pauli tensors.

Function Documentation

◆ applyTrotterizedPauliStrSumGadget()

void applyTrotterizedPauliStrSumGadget ( Qureg qureg,
PauliStrSum sum,
qreal angle,
int order,
int reps )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 893 of file operations.cpp.

893 {
894 validate_quregFields(qureg, __func__);
895 validate_pauliStrSumFields(sum, __func__);
896 validate_pauliStrSumTargets(sum, qureg, __func__);
897 validate_pauliStrSumIsHermitian(sum, __func__);
898 validate_trotterParams(qureg, order, reps, __func__);
899
900 /// @todo
901 /// the accuracy of Trotterisation is greatly improved by randomisation
902 /// or (even sub-optimal) grouping into commuting terms. Should we
903 /// implement these here or into another function?
904
905 if (angle == 0)
906 return;
907
908 for (int r=0; r<reps; r++)
909 applyHigherOrderTrotter(qureg, sum, angle/reps, order);
910}

◆ multiplyPauliStrSum()

void multiplyPauliStrSum ( Qureg qureg,
PauliStrSum sum,
Qureg workspace )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 836 of file operations.cpp.

836 {
837 validate_quregFields(qureg, __func__);
838 validate_quregFields(workspace, __func__);
839 validate_quregCanBeWorkspace(qureg, workspace, __func__);
840 validate_pauliStrSumFields(sum, __func__);
841 validate_pauliStrSumTargets(sum, qureg, __func__);
842
843 // clone qureg to workspace, set qureg to blank
844 localiser_statevec_setQuregToSuperposition(0, workspace, 1, qureg, 0, qureg);
845 localiser_statevec_initUniformState(qureg, 0);
846
847 // apply each term in-turn, mixing into output qureg, then undo using idempotency
848 for (qindex i=0; i<sum.numTerms; i++) {
849 localiser_statevec_anyCtrlPauliTensor(workspace, {}, {}, sum.strings[i]);
850 localiser_statevec_setQuregToSuperposition(1, qureg, sum.coeffs[i], workspace, 0, workspace);
851 localiser_statevec_anyCtrlPauliTensor(workspace, {}, {}, sum.strings[i]);
852 }
853
854 // workspace -> qureg, and qureg -> sum * qureg
855}

Referenced by TEST_CASE().