discretize.tests.get_quadratic#

discretize.tests.get_quadratic(A, b, c=0)[source]#

Return a function that evaluates the given quadratic.

Given A, b and c, this returns a function that evaluates the quadratic for a vector x. Where \(\mathbf{A} \in \mathbb{R}^{NxN}\), \(\mathbf{b} \in \mathbb{R}^N\) and \(c\) is a constant, this function evaluates the following quadratic:

\[Q( \mathbf{x} ) = \frac{1}{2} \mathbf{x^T A x + b^T x} + c\]

for a vector \(\mathbf{x}\). It also optionally returns the gradient of the above equation, and its Hessian.

Parameters:
A(N, N) numpy.ndarray

A square matrix

b(N) numpy.ndarray

A vector

cfloat

A constant

Returns:
function

The callable function that returns the quadratic evaluation, and optionally its gradient, and Hessian.