Skip to main content

extract_quadratic

Function extract_quadratic 

Source
pub fn extract_quadratic(
    arena: &ExprArena,
    id: ExprId,
) -> Option<QuadraticTerms>
Expand description

Snapshot the quadratic structure of id, if it is a polynomial of degree <= 2. Returns the Hessian (lower triangle), the linear coefficients, and the constant (see QuadraticTerms).

None is returned for any expression classify would call Nonlinear (degree > 2, transcendentals, non-integer/negative powers, division). Parameters are folded to their current arena values, so a polynomial whose coefficients are parameters is still extracted.

A purely linear (or constant) expression yields an empty hessian.