SG++-Doxygen-Documentation
sgpp::optimization::ComponentScalarFunction Class Reference

One component of a vector-valued function. More...

#include <ComponentScalarFunction.hpp>

Inheritance diagram for sgpp::optimization::ComponentScalarFunction:
sgpp::optimization::ScalarFunction

Public Member Functions

void clone (std::unique_ptr< ScalarFunction > &clone) const override
 
 ComponentScalarFunction (ScalarFunction &f, std::vector< double > defaultValues=std::vector< double >())
 Constructor. More...
 
 ComponentScalarFunction (VectorFunction &f, size_t k, std::vector< double > defaultValues=std::vector< double >())
 Constructor. More...
 
double eval (const base::DataVector &x) override
 
 ~ComponentScalarFunction () override
 Destructor. More...
 
- Public Member Functions inherited from sgpp::optimization::ScalarFunction
size_t getNumberOfParameters () const
 
 ScalarFunction (size_t d)
 Constructor. More...
 
virtual ~ScalarFunction ()
 Destructor. More...
 

Protected Member Functions

void initialize ()
 

Protected Attributes

std::vector< double > defaultValues
 vector of default values, indicating free variables with NAN More...
 
size_t dF
 dimension of underlying function More...
 
ScalarFunctionfScalar
 scalar-valued function More...
 
VectorFunctionfVector
 vector-valued function More...
 
size_t k
 index of component More...
 
base::DataVector tmpVec1
 temporary vector 1 More...
 
base::DataVector tmpVec2
 temporary vector 2 More...
 
- Protected Attributes inherited from sgpp::optimization::ScalarFunction
size_t d
 dimension of the domain More...
 

Detailed Description

One component of a vector-valued function.

Given a vector-valued \(f\colon [0, 1]^d \to \mathbb{R}^m\) and indices \(1 \le i_1 < \dotsb < i_n \le d\), this class represents a new function \(g\colon [0, 1]^n \to \mathbb{R}\) with \(g(y_{i_1}, \dotsc, y_{i_n}) := f_k(y_1, \dotsc, y_d)\), where \(y_t\) is constant for \(t \in \{i_1, \dotsc, i_n\}\).

The resulting function \(g\) is similar to a "slice plot" of the component \(f_k\) of \(f\).

Constructor & Destructor Documentation

◆ ComponentScalarFunction() [1/2]

sgpp::optimization::ComponentScalarFunction::ComponentScalarFunction ( ScalarFunction f,
std::vector< double >  defaultValues = std::vector<double>() 
)
inline

Constructor.

Use it like this: ComponentScalarFunction g(f, {NAN, NAN, 0.42}); where f is a scalar-valued function with 3 parameters. This selects the first two parameters of f, while constantly using 0.42 for the third parameter.

Parameters
fscalar-valued function
defaultValuesVector of constant default values. It can be either empty (the default) or a vector of exactly m doubles, each of which can be finite or NAN. If the vector is empty, it will be initialized as m NANs (i.e., no restriction of the parameter domain). Each NAN represents a free parameter \(x_t\), while the finite entries denote the constant values for the corresponding parameter.

References initialize().

Referenced by clone().

◆ ComponentScalarFunction() [2/2]

sgpp::optimization::ComponentScalarFunction::ComponentScalarFunction ( VectorFunction f,
size_t  k,
std::vector< double >  defaultValues = std::vector<double>() 
)
inline

Constructor.

Use it like this: ComponentScalarFunction g(f, 3, {NAN, NAN, 0.42}); where f is a vector-valued function with 5 components and 3 parameters. This selects the first two parameters and the fourth component of f, while constantly using 0.42 for the third parameter.

Parameters
fvector-valued function (m components)
kindex of component \(f_k\) to select (between 0 and m - 1)
defaultValuessee other constructor

References initialize().

◆ ~ComponentScalarFunction()

sgpp::optimization::ComponentScalarFunction::~ComponentScalarFunction ( )
inlineoverride

Destructor.

Member Function Documentation

◆ clone()

void sgpp::optimization::ComponentScalarFunction::clone ( std::unique_ptr< ScalarFunction > &  clone) const
inlineoverridevirtual
Parameters
[out]clonepointer to cloned object

Implements sgpp::optimization::ScalarFunction.

References ComponentScalarFunction().

◆ eval()

double sgpp::optimization::ComponentScalarFunction::eval ( const base::DataVector x)
inlineoverridevirtual
Parameters
xevaluation point \(\vec{x} \in [0, 1]^n\)
Returns
\(g(\vec{x}) := f_k(y_1, \dotsc, y_d)\) where \((x_1, \dotsc, x_n) = (y_{i_1}, \dotsc, y_{i_n})\)

Implements sgpp::optimization::ScalarFunction.

References defaultValues, dF, sgpp::optimization::ScalarFunction::eval(), sgpp::optimization::VectorFunction::eval(), fScalar, fVector, k, tmpVec1, and tmpVec2.

◆ initialize()

void sgpp::optimization::ComponentScalarFunction::initialize ( )
inlineprotected

References dF.

Referenced by ComponentScalarFunction().

Member Data Documentation

◆ defaultValues

std::vector<double> sgpp::optimization::ComponentScalarFunction::defaultValues
protected

vector of default values, indicating free variables with NAN

Referenced by eval().

◆ dF

size_t sgpp::optimization::ComponentScalarFunction::dF
protected

dimension of underlying function

Referenced by eval(), and initialize().

◆ fScalar

ScalarFunction* sgpp::optimization::ComponentScalarFunction::fScalar
protected

scalar-valued function

Referenced by eval().

◆ fVector

VectorFunction* sgpp::optimization::ComponentScalarFunction::fVector
protected

vector-valued function

Referenced by eval().

◆ k

size_t sgpp::optimization::ComponentScalarFunction::k
protected

index of component

Referenced by eval().

◆ tmpVec1

base::DataVector sgpp::optimization::ComponentScalarFunction::tmpVec1
protected

temporary vector 1

Referenced by eval().

◆ tmpVec2

base::DataVector sgpp::optimization::ComponentScalarFunction::tmpVec2
protected

temporary vector 2

Referenced by eval().


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