Skip to main content

canonical

Function canonical 

Source
pub fn canonical(
    graph: &Graph,
    file: &str,
    position: Position,
) -> Result<Polynomial, Error>
Expand description

Expands graph into its canonical polynomial.

The graph is walked iteratively in node order, so the depth of the expression does not matter. A node’s polynomial is dropped after its last use, which keeps long sums linear in memory.

§Errors

Returns an error, at position in file, when the expansion is too large: a polynomial with more than 2^16 terms, a coefficient of more than 2^16 bits, a term of degree above u32::MAX, or more than 2^20 units of work, a unit being one product or sum of two coefficients of up to 64 bits or one term copied. Each limit is checked before the work it guards, so an expansion that is too large fails quickly.