| 1306 | |
| 1307 | |
| 1308 | string getPauliStrAsString(PauliStr str, int numPauliChars=0) { |
| 1309 | |
| 1310 | // numPauliChars (only used by all-qubits reporting format) |
| 1311 | // allows the caller to pad the printed PauliStr with left I, |
| 1312 | // useful when reporting a truncated PauliStrSum to ensure |
| 1313 | // the top and bottom partitions are aligned and equal width. |
| 1314 | // When not passed, it defaults to minimum padding |
| 1315 | if (numPauliChars == 0) |
| 1316 | numPauliChars = 1 + paulis_getIndOfLefmostNonIdentityPauli(str); |
| 1317 | |
| 1318 | /// @todo |
| 1319 | /// to be absolutely pedantic/defensively-designed, we should |
| 1320 | /// assert numPauliChars >= 1+paulis_getIndOfLefmostNonIdentityPauli |
| 1321 | /// to ensure a bug never occludes a PauliStr. Very low priority! |
| 1322 | |
| 1323 | switch(global_pauliStrFormatFlag) { |
| 1324 | case 0: return getPauliStrAsAllQubitsString(str, numPauliChars); |
| 1325 | case 1: return getPauliStrAsIndexString(str, numPauliChars); |
| 1326 | } |
| 1327 | |
| 1328 | /// @todo |
| 1329 | /// to be defensively-designed, we should throw a runtime error |
| 1330 | /// here because global_pauliStrFormatFlag was mutilated. This is |
| 1331 | /// a very low priority; so we just return a suspicious string! |
| 1332 | return "(PauliStr stringifying failed - please alert the QuEST devs)"; |
| 1333 | } |
| 1334 | |
| 1335 | |
| 1336 | void print_elemsWithoutNewline(PauliStr str, string indent) { |
no test coverage detected