Affine-plus-quadratic expression a^T x + x^T C x + b, sparse over variable
ids. terms holds the linear part; qterms holds quadratic coefficients
keyed by normalized {lo_id, hi_id} pairs (so x*y and y*x sum into one
cell, and x*x lives at {i, i}). Coefficients are literal: the qterm
coefficient of {i, j} is exactly the coefficient of x_i * x_j as
written. Products of degree greater than two raise Optex.NonlinearError.
Summary
Functions
Add two expressions; coefficients of shared cells sum.
The affine expression 1.0 * var.
Multiply two normalized leaves. Numbers and constant-only expressions
scale; the product of two linear expressions yields quadratic terms; any
product whose degree would exceed two raises Optex.NonlinearError.
Whether the expression carries any quadratic terms.
Multiply every coefficient and the constant by a number.
Normalize a leaf (variable, number, or Aff) to an Aff.
Types
@type t() :: %Optex.Aff{ constant: float(), qterms: %{required({non_neg_integer(), non_neg_integer()}) => float()}, terms: %{required(non_neg_integer()) => float()} }
Functions
Add two expressions; coefficients of shared cells sum.
The affine expression 1.0 * var.
Multiply two normalized leaves. Numbers and constant-only expressions
scale; the product of two linear expressions yields quadratic terms; any
product whose degree would exceed two raises Optex.NonlinearError.
Whether the expression carries any quadratic terms.
Multiply every coefficient and the constant by a number.
Normalize a leaf (variable, number, or Aff) to an Aff.