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

Function parser_parseComplex

quest/src/core/parser.cpp:308–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307
308qcomp parser_parseComplex(string str) {
309
310 if (!parser_isValidComplex(str))
311 error_attemptedToParseComplexFromInvalidString();
312
313 // we are gauranteed to fully match real, imag or comp after prior validation
314 smatch match;
315
316 // extract and parse components and their signs (excluding imaginary symbol)
317 if (regex_match(str, match, regexes::real))
318 return qcomp(parser_parseReal(match.str(1)), 0);
319
320 if (regex_match(str, match, regexes::imag))
321 return qcomp(0, parser_parseReal(match.str(1)));
322
323 if (regex_match(str, match, regexes::comp))
324 return qcomp(
325 parser_parseReal(match.str(1)),
326 parser_parseReal(match.str(2)));
327
328 // should be unreachable
329 error_attemptedToParseComplexFromInvalidString();
330 return qcomp(0,0);
331}
332
333
334

Callers 1

parseWeightedPaulisFunction · 0.85

Tested by

no test coverage detected