29 : FunctionBase { size }, coefficients( size ){ coefficients.set_all( 0.0 ); }
34 size_t const MIN { std::min( size,
coefficients.size() ) };
38 for(
size_t index { 0 }; index < MIN; ++index )
41 for(
size_t index { MIN }; index <
coefficients.size(); ++index )
50 throw IPOE(
"ipo_function::concrete::LinearCombination::setCoefficient(): "
51 "index out of range." );
60 throw IPOE(
"ipo_function::concrete::LinearCombination::getCoefficient(): "
61 "index out of range." );
76 ost {
"ipo_function::concrete::LinearCombination::setCoefficients(): " };
77 ost <<
"vector size " << vector.size();
79 ost <<
" do not match.";
80 throw IPOE( ost.str() );
89 std::ostringstream ost {
"ipo_function::concrete::LinearCombination::operator()(): " };
90 ost <<
"vector size " << vector.size();
92 ost <<
" do not match.";
93 throw IPOE( ost.str() );
95 double result { 0.0 };
102 size_t const SIZE { vector.size() };
105 std::ostringstream ost {
"ipo_function::concrete::LinearCombination::gradient(): " };
106 ost <<
"vector size " << vector.size();
107 ost <<
" and coefficients size " <<
coefficients.size();
108 ost <<
" do not match.";
109 throw IPOE( ost.str() );
120 size_t const SIZE { vector.size() };
123 std::ostringstream ost {
"ipo_function::concrete::LinearCombination::hessian(): " };
124 ost <<
"vector size " << vector.size();
125 ost <<
" and coefficients size " <<
coefficients.size();
126 ost <<
" do not match.";
127 throw IPOE( ost.str() );
137 size_t const SIZE { vector.size() };
140 std::ostringstream ost {
"ipo_function::concrete::LinearCombination::setVector(): " };
141 ost <<
"vector size " << vector.size();
142 ost <<
" and coefficients size " <<
coefficients.size();
143 ost <<
" do not match.";
144 throw IPOE( ost.str() );
void setCoefficient(size_t const index, double const value)
Set the value of a coefficient.
double functionValue
The function value.
gsl::vector coefficients
The vector of coefficients;.
gsl::vector functionGradient
The gradient value.
virtual gsl::matrix hessian() const
virtual gsl::vector gradient() const
virtual double value() const
gsl::matrix functionHessian
The Hessian value.
virtual void setVector(gsl::vector const &vector)
Set a vector and compute function value, gradient and Hessian efficiently.
Namespace to hold concrete functions.
#define IPOE(message)
Macro to allow file and line names in exceptions.
virtual double operator()(gsl::vector const &vector)
The function operator: computes the sum of the vector entries.
double getCoefficient(size_t const index) const
Get the value of a coefficient.
void setCoefficients(gsl::vector const &vector)
Set coefficients from a vector.
void resize(size_t const size)
Resize the vector of coefficients.
LinearCombination(size_t const size=0)
The constructor sets up function as a linear combination of size entries.
size_t const size
Size of vector arguments to supply to subclass functions.
gsl::vector const & getCoefficients() const
Get the coefficients as a vector by reference.
This namespace holds all the interior-point optimisation classes.