ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
complex_utils Namespace Reference

Functions

bool parse_complex_string (const std::string &raw, double &real_out, double &imag_out)
 Parses a Python complex literal string into (real, imag) components.
exprt raise_math_real_type_error_expr (python_converter &converter)
 Generates a TypeError expression for math functions that reject complex arguments: "must be real number, not complex".
exprt raise_math_int_type_error_expr (python_converter &converter)
 Generates a TypeError expression for functions that require an integer but received a complex: "'complex' object cannot be interpreted as an integer".

Function Documentation

◆ parse_complex_string()

bool complex_utils::parse_complex_string ( const std::string & raw,
double & real_out,
double & imag_out )

Parses a Python complex literal string into (real, imag) components.

Handles all CPython-accepted formats: "1+2j", "(3-4.5j)", "2j", "1.5", "+j", "-j", scientific notation like "1e3+2e-1j", etc.

Parameters
rawInput string (may include whitespace and wrapping parentheses).
real_outOutput real part.
imag_outOutput imaginary part.
Returns
true on success, false if the string is malformed.

◆ raise_math_int_type_error_expr()

exprt complex_utils::raise_math_int_type_error_expr ( python_converter & converter)

Generates a TypeError expression for functions that require an integer but received a complex: "'complex' object cannot be interpreted as an integer".

◆ raise_math_real_type_error_expr()

exprt complex_utils::raise_math_real_type_error_expr ( python_converter & converter)

Generates a TypeError expression for math functions that reject complex arguments: "must be real number, not complex".