MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / getPauliStr

Function getPauliStr

quest/src/api/paulis.cpp:76–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76extern "C" PauliStr getPauliStr(const char* paulis, int* indices, int numPaulis) {
77 validate_newPauliStrParams(paulis, indices, numPaulis, MAX_NUM_PAULIS_PER_STR, __func__);
78
79 // begin masks at all-identity 'I' = 0
80 PAULI_MASK_TYPE lowPaulis = 0;
81 PAULI_MASK_TYPE highPaulis = 0;
82
83 // change targeted indices to the given Paulis
84 for (int i=0; i<numPaulis; i++) {
85
86 // cast single Pauli to full precision mask to enable below shifts
87 auto pauli = (PAULI_MASK_TYPE) parser_getPauliIntFromChar(paulis[i]);
88
89 // add the Pauli to either the lower or upper pauli masks
90 if (indices[i] < MAX_NUM_PAULIS_PER_MASK)
91 lowPaulis |= pauli << (2*indices[i]);
92 else
93 highPaulis |= pauli << (2*(indices[i] - MAX_NUM_PAULIS_PER_MASK));
94 }
95
96 // return a new stack PauliStr instance (avoiding C++20 initialiser)
97 PauliStr out;
98 out.lowPaulis = lowPaulis;
99 out.highPaulis = highPaulis;
100 return out;
101}
102
103
104PauliStr getPauliStr(int* paulis, int* indices, int numPaulis) {

Callers 15

getRandomPauliStrFunction · 0.85
getRandomDiagPauliStrFunction · 0.85
getFixedRemainingArgsFunction · 0.85
testOperationValidationFunction · 0.85
SECTIONFunction · 0.85
getRandomPauliStrFunction · 0.85
getRandomDiagPauliStrFunction · 0.85
parsePaulisFunction · 0.85
leftapplyPauliXFunction · 0.85
leftapplyPauliYFunction · 0.85

Tested by 2

getRandomPauliStrFunction · 0.68
getRandomDiagPauliStrFunction · 0.68