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

Functions for modifying existing Pauli data structures. More...

Functions

void sortPauliStrSumLexicographic (PauliStrSum sum)
 
void sortPauliStrSumMagnitude (PauliStrSum sum)
 

Detailed Description

Functions for modifying existing Pauli data structures.

Function Documentation

◆ sortPauliStrSumLexicographic()

void sortPauliStrSumLexicographic ( PauliStrSum sum)

Reorders the terms within a sum of weighted Pauli strings so that the Pauli strings are ordered lexicographically.

Formulae

Let \( H = \) sum, satisfying

\[ H = \sum\limits_j c_j \, \hat{\sigma}_j \]

where \( c_j \) is the coefficient of the \( j \)-th PauliStr \( \hat{\sigma}_j \).

This function applies the permutation \( \pi \) to \( H \), whereby

\[ H = \sum\limits_j c_{\pi(j)} \, \hat{\sigma}_{\pi(j)} \]

such that

\[ \hat{\sigma}_{\pi(i)} <_{lex} \hat{\sigma}_{\pi(j)} \ \forall \ \pi(i) < \pi(j). \]

Parameters
[in,out]suma weighted sum of Pauli strings to reorder.
Exceptions
error
  • if sum is not initialised.
See also
Author
Vasco Ferreira

Definition at line 310 of file paulis.cpp.

310 {
311 validate_pauliStrSumFields(sum, __func__);
312
313 auto lexSort = [&](qindex i, qindex j) {
314 PauliStr strI = sum.strings[i];
315 PauliStr strJ = sum.strings[j];
316 return std::tie(strI.highPaulis, strI.lowPaulis) < std::tie(strJ.highPaulis, strJ.lowPaulis);
317 };
318
319 auto errFunc = [&](size_t numBytes) { validate_tempAllocSucceeded(false, numBytes, __func__); };
320 paulis_sortTermsViaComparator(sum, lexSort, errFunc);
321}

◆ sortPauliStrSumMagnitude()

void sortPauliStrSumMagnitude ( PauliStrSum sum)

Reorders the terms within a sum of weighted Pauli strings such that coefficients are ordered with decreasing magnitude.

Formulae

Let \( H = \) sum, satisfying

\[ H = \sum\limits_j c_j \, \hat{\sigma}_j \]

where \( c_j \) is the coefficient of the \( j \)-th PauliStr \( \hat{\sigma}_j \).

This function applies the permutation \( \pi \) to \( H \) such that

\[ |c_{\pi(i)}| > |c_{\pi(j)}| \, \forall \, \pi(i) < \pi(j). \]

Parameters
[in,out]suma weighted sum of Pauli strings to reorder.
Exceptions
error
  • if sum is not initialised.
See also
Author
Vasco Ferreira

Definition at line 324 of file paulis.cpp.

324 {
325 validate_pauliStrSumFields(sum, __func__);
326
327 auto magSort = [&](qindex i, qindex j) {
328 return std::norm(sum.coeffs[i]) > std::norm(sum.coeffs[j]);
329 };
330
331 auto errFunc = [&](size_t numBytes) { validate_tempAllocSucceeded(false, numBytes, __func__); };
332 paulis_sortTermsViaComparator(sum, magSort, errFunc);
333}