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

Function separateStringIntoCoeffAndPaulis

quest/src/core/parser.cpp:147–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145
146
147void separateStringIntoCoeffAndPaulis(string line, string &coeff, string &paulis) {
148
149 // absolutely gauranteed to match due to prior matching of regexes::line
150 smatch match;
151
152 // locate the coefficient
153 regex_search(line, match, regexes::num);
154 coeff = match.str(0);
155
156 // the remainder of the line must be the paulis, but we explicitly match to
157 // regex just in case we later permit additional substrings like comments.
158 // we must match only the substring AFTER the coeff, since valid coeffs (e.g.
159 // 1) can be mistaken for a Pauli code.
160 line = line.substr(match.position(0) + match.length(0));
161 regex_search(line, match, regexes::paulis);
162 paulis = match.str(0);
163}
164
165
166int getNumPaulisInLine(string line) {

Callers 3

getNumPaulisInLineFunction · 0.85
parseWeightedPaulisFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected