Prev Next

Check Sparse Quadratic Function and Derivatives

Syntax
# include <cppad/speed/quadratic_ok.hpp>
ok = quadratic_ok(nijxmfm)

Purpose
We define the function  f : \R^n \rightarrow \R  defined by  \[
        f(x) = \sum_{k=1}^\ell \exp ( x_{i[k]} x_{j[k]} )
\] 
This routine can be used to check a method for computing  f(x) ,  f^{(1)} (x) , or  f^{(2)} (x) .

Inclusion
The template function quadratic_ok is defined in the CppAD namespace by including the file cppad/speed/quadratic_ok.hpp (relative to the CppAD distribution directory). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

n
The argument n has prototype
     size_t 
n
and is the dimension of the argument space for the function  f .

i
The argument i has prototype
      const CppAD::vector<size_t> &
i
and is a vector with size  \ell . It specifies one of the first index of  x for each quadratic term in  f(x) . All the elements of i must be between zero and n-1.

j
The argument j has prototype
      const CppAD::vector<size_t> &
j
and is a vector with size  \ell . It specifies one of the second index of  x for each quadratic term in  f(x) . All the elements of j must be between zero and n-1.

x
The argument x has prototype
     const CppAD::vector<double> &
x
and its size is n. It contains he argument value for which the derivative is being checked. Note that if m is zero, the derivative does not depend on  x and you can use any value for its elements.

m
The argument m has prototype
     size_t 
m
It specifies the order of the derivative of  f that is being checked; i.e.,  f^{(m)} (x) is checked.

fm
The argument fm has prototype
     const CppAD::vector<double> &
fm
and contains the value of  f^{(m)} (x) that is being checked.

Function
If m is zero, fm has size one and fm[0] is the value of  f(x) .

Gradient
If m is one, fm has size n and for  j = 0 , \ldots , n-1  \[
     \D{f}{x[j]} = fm [ j ]
\] 


Hessian
If m is two, fm has size n * n and for  k = 0 , \ldots , n-1 ,  m = 0 , \ldots , n-1  \[
     \DD{f}{x[k]}{x[m]} = fm [ k * n + m ]
\] 


ok
The return value ok has prototype
     bool 
ok
It is true, if hessian passes the test and false otherwise.

Source Code
The file quadratic_ok.hpp contains the source code for this template function.
Input File: cppad/speed/quadratic_ok.hpp