Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
ipo_function::concrete::QuadraticCombination Class Reference

This class provides function objects representing quadratic combinations of the elements of their matrix of arguments. More...

#include <QuadraticCombination.hpp>

Inheritance diagram for ipo_function::concrete::QuadraticCombination:
Inheritance graph
Collaboration diagram for ipo_function::concrete::QuadraticCombination:
Collaboration graph

Public Member Functions

 QuadraticCombination (size_t const size=0)
 The constructor sets up function as a quadratic combination of size entries. More...
 
void resize (size_t const size)
 Resize the matrix of coefficients. More...
 
void setCoefficient (size_t const index, double const value)
 Set the value of a coefficient on the diagonal. More...
 
void setCoefficient (size_t const row, size_t const col, double const value)
 Set the value of a coefficient. More...
 
double getCoefficient (size_t const index) const
 Get the value of a coefficient on the diagonal. More...
 
double getCoefficient (size_t const row, size_t const col) const
 Get the value of a coefficient. More...
 
gsl::matrix const & getCoefficients () const
 Get the coefficients as a matrix by reference. More...
 
void setCoefficients (gsl::matrix const &matrix)
 Set coefficients from a matrix. More...
 
virtual double operator() (gsl::vector const &vector)
 The function operator: computes the sum of the vector entries. More...
 
virtual gsl::vector gradient (gsl::vector const &vector)
 The function operator: returns the gradient: the coefficients. More...
 
virtual gsl::matrix hessian (gsl::vector const &vector)
 The function operator: returns the Hessian: a matrix of 0s. More...
 
virtual void setVector (gsl::vector const &vector)
 Set a vector and compute function value, gradient and Hessian efficiently. More...
 
- Public Member Functions inherited from ipo_function::Function
 Function (size_t const size=0)
 Constructor. More...
 
virtual std::tuple
< gsl::vector, gsl::matrix > 
derivatives (gsl::vector const &vector)
 Compute or estimate derivative values. More...
 
- Public Member Functions inherited from ipo_function::detail::FunctionBase
 FunctionBase (size_t const size=0)
 Constructor. More...
 
virtual ~FunctionBase ()=0
 Make the class abstract. More...
 
size_t getSize () const
 Get size of vector for function arguments or zero for arbitrary size. More...
 
- Public Member Functions inherited from ipo_function::DerivativesEstimates
 DerivativesEstimates (size_t const size=0)
 Constructor. More...
 
virtual gsl::matrix hessian () const
 
- Public Member Functions inherited from ipo_function::GradientEstimate
 GradientEstimate (size_t const size=0)
 Constructor. More...
 
virtual double value () const
 
virtual gsl::vector gradient () const
 

Protected Attributes

gsl::matrix coefficients
 The matrix of coefficients;. More...
 
- Protected Attributes inherited from ipo_function::Function
double h = std::sqrt( std::numeric_limits<double>::epsilon() )
 Value used for default gradient estimates. More...
 
double h2 = std::sqrt( h )
 Value used for default Hessian estimates. More...
 
- Protected Attributes inherited from ipo_function::detail::FunctionBase
size_t const size
 Size of vector arguments to supply to subclass functions. More...
 
- Protected Attributes inherited from ipo_function::DerivativesEstimates
gsl::matrix functionHessian
 The Hessian value. More...
 
- Protected Attributes inherited from ipo_function::GradientEstimate
double functionValue
 The function value. More...
 
gsl::vector functionGradient
 The gradient value. More...
 

Detailed Description

This class provides function objects representing quadratic combinations of the elements of their matrix of arguments.

Each object of this class stores a symmetric $k\times k$ matrix $C$ of coefficients. When the function object is called with a vector argument $\mathbf{v}=(v_1,\ldots,v_k)^\top$ it returns $\mathbf{v}C\mathbf{v}^\top$. Note that the coefficient of $x_ix_j$ is twice the $(i,j)$th element of $C$ when $i\ne j$.

Definition at line 38 of file QuadraticCombination.hpp.

Constructor & Destructor Documentation

QuadraticCombination::QuadraticCombination ( size_t const  size = 0)

The constructor sets up function as a quadratic combination of size entries.

Initially the coefficient of each entry is zero so that a call to function returns zero.

Parameters
sizeThe size of vectors in the function and derivatives

Definition at line 28 of file QuadraticCombination.cc.

Member Function Documentation

double QuadraticCombination::getCoefficient ( size_t const  index) const

Get the value of a coefficient on the diagonal.

Parameters
indexThe index of the coefficient
Returns
The value of the coefficient
Exceptions
IPOExceptionif index out of range

Definition at line 82 of file QuadraticCombination.cc.

References coefficients, and IPOE.

Referenced by getCoefficient().

double QuadraticCombination::getCoefficient ( size_t const  row,
size_t const  col 
) const

Get the value of a coefficient.

It doesn’t matter here if row and col values are interchanged because the coefficient matrix is symmetric.

Parameters
rowThe row index of the coefficient
colThe column index of the coefficient
Returns
The value of the coefficient
Exceptions
IPOExceptionif row or col out of range

Definition at line 92 of file QuadraticCombination.cc.

References coefficients, getCoefficient(), and IPOE.

gsl::matrix const & QuadraticCombination::getCoefficients ( ) const

Get the coefficients as a matrix by reference.

Returns
the vector of coefficients

Definition at line 108 of file QuadraticCombination.cc.

References coefficients.

gsl::vector QuadraticCombination::gradient ( gsl::vector const &  vector)
virtual

The function operator: returns the gradient: the coefficients.

The return value may change if the coefficients change.

Parameters
vectorA vector argument
Returns
The gradient

Reimplemented from ipo_function::Function.

Definition at line 164 of file QuadraticCombination.cc.

References coefficients, ipo_function::GradientEstimate::functionGradient, and IPOE.

gsl::matrix QuadraticCombination::hessian ( gsl::vector const &  vector)
virtual

The function operator: returns the Hessian: a matrix of 0s.

The return value may change if the number of coefficients change.

Parameters
vectorA vector argument
Returns
The Hessian: a constant symmetric matrix

Reimplemented from ipo_function::Function.

Definition at line 187 of file QuadraticCombination.cc.

References coefficients, ipo_function::DerivativesEstimates::functionHessian, and IPOE.

double QuadraticCombination::operator() ( gsl::vector const &  vector)
virtual

The function operator: computes the sum of the vector entries.

Parameters
vectorA vector argument
Returns
The quadratic form evaluated at vector

Implements ipo_function::Function.

Definition at line 147 of file QuadraticCombination.cc.

References coefficients, and IPOE.

void QuadraticCombination::resize ( size_t const  size)

Resize the matrix of coefficients.

Any new entries are set to zero.

Parameters
sizeThe new size

Definition at line 32 of file QuadraticCombination.cc.

References coefficients, and ipo_function::detail::FunctionBase::size.

void QuadraticCombination::setCoefficient ( size_t const  index,
double const  value 
)

Set the value of a coefficient on the diagonal.

Parameters
indexThe index of the coefficient
valueThe new value of the coefficient
Exceptions
IPOExceptionif index out of range

Definition at line 52 of file QuadraticCombination.cc.

References coefficients, and IPOE.

Referenced by setCoefficient().

void QuadraticCombination::setCoefficient ( size_t const  row,
size_t const  col,
double const  value 
)

Set the value of a coefficient.

The values of row and col can be interchanged without affecting the result.

Parameters
rowThe row index of the coefficient
colThe column index of the coefficient
valueThe new value of the coefficient
Exceptions
IPOExceptionif row or col out of range

Definition at line 62 of file QuadraticCombination.cc.

References coefficients, IPOE, and setCoefficient().

void QuadraticCombination::setCoefficients ( gsl::matrix const &  matrix)

Set coefficients from a matrix.

This can resize the coefficients.

Parameters
matrixThe new coefficients matrix
Exceptions
IPOExceptionif matrix is not symmetric or has wrong size

Definition at line 113 of file QuadraticCombination.cc.

References coefficients, and IPOE.

void QuadraticCombination::setVector ( gsl::vector const &  vector)
virtual

Set a vector and compute function value, gradient and Hessian efficiently.

Parameters
vectorA vector argument

Implements ipo_function::GradientEstimate.

Definition at line 205 of file QuadraticCombination.cc.

References coefficients, ipo_function::GradientEstimate::functionGradient, ipo_function::DerivativesEstimates::functionHessian, ipo_function::GradientEstimate::functionValue, and IPOE.

Member Data Documentation

gsl::matrix ipo_function::concrete::QuadraticCombination::coefficients
protected

The matrix of coefficients;.

Definition at line 127 of file QuadraticCombination.hpp.

Referenced by getCoefficient(), getCoefficients(), gradient(), hessian(), operator()(), resize(), setCoefficient(), setCoefficients(), and setVector().


The documentation for this class was generated from the following files: