37 const size_t SIZE { vector.size() };
40 = gsl::vector( SIZE );
41 auto diffMatrix = gsl::matrix( SIZE, SIZE );
43 for(
size_t i { 0 }; i < SIZE; ++i ){
44 double tmp { vector.get( i ) };
45 const_cast<gsl::vector&
>( vector ).set( i, tmp +
h2 );
46 diffVector2.set( i,
function( vector ) );
47 const_cast<gsl::vector&
>( vector ).set( i, tmp );
50 for(
size_t i { 0 }; i < SIZE; ++i ){
51 double tmp1 { vector.get( i ) };
52 const_cast<gsl::vector&
>( vector ).set( i, tmp1 + 2 *
h2 );
53 diffMatrix.set( i, i,
function( vector ) );
54 const_cast<gsl::vector&
>( vector ).set( i, tmp1 +
h2 );
55 for(
size_t j { i + 1 }; j < SIZE; ++j ){
56 double tmp2 { vector.get( j ) };
57 const_cast<gsl::vector&
>( vector ).set( j, tmp2 +
h2 );
58 diffMatrix.set( i, j,
function( vector ) );
59 const_cast<gsl::vector&
>( vector ).set( j, tmp2 );
61 const_cast<gsl::vector&
>( vector ).set( i, tmp1 );
70 double const H {
h2 *
h2 };
71 for(
size_t i { 0 }; i < SIZE; ++i ){
72 double const diff { (diffMatrix.get( i, i ) - 2 * diffVector2.get( i )
75 for(
size_t j { i + 1 }; j < SIZE; ++j ){
76 double const diff { (diffMatrix.get( i, j ) - diffVector2.get( i )
virtual void setVector(gsl::vector const &vector)
Set the vector to a new value.
double functionValue
The function value.
virtual void setVector(gsl::vector const &vector)
Set the vector to a new value.
This class estimates a function value, gradient and Hessian at a given vector.
Namespace for details of ipo_function that are not normally needed to construct and solve a convex op...
gsl::matrix functionHessian
The Hessian value.
This class computes a function at a vector.
double const h2
The quotient size for hessian estimates: default is fourth root of machine epsilon.
ForwardDifferenceDerivativesEstimates(Function &function, double const h=std::sqrt(std::numeric_limits< double >::epsilon()), double const h2=std::sqrt(std::sqrt(std::numeric_limits< double >::epsilon())))
Find forward difference quotient estimates.