13 #ifndef MLPACK_CORE_OPTIMIZERS_FUNCTION_ADD_GRADIENT_HPP 14 #define MLPACK_CORE_OPTIMIZERS_FUNCTION_ADD_GRADIENT_HPP 20 namespace optimization {
26 template<
typename FunctionType,
27 bool HasEvaluateWithGradient =
28 traits::HasEvaluateWithGradient<FunctionType,
30 bool HasGradient = traits::HasGradient<FunctionType,
42 template<
typename FunctionType,
bool HasEvaluateWithGradient>
43 class AddGradient<FunctionType, HasEvaluateWithGradient, true>
47 void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
50 this))->Gradient(coordinates, gradient);
58 template<
typename FunctionType>
68 void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
72 coordinates, gradient);
80 template<
typename FunctionType,
81 bool HasEvaluateWithGradient =
82 traits::HasEvaluateWithGradient<FunctionType,
84 bool HasGradient = traits::HasGradient<FunctionType,
96 template<
typename FunctionType,
bool HasEvaluateWithGradient>
101 void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
const 103 static_cast<const FunctionType*
>(
static_cast<const
113 template<
typename FunctionType>
123 void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
const 136 template<
typename FunctionType,
137 bool HasEvaluateWithGradient =
138 traits::HasEvaluateWithGradient<FunctionType,
140 bool HasGradient = traits::HasGradient<FunctionType,
152 template<
typename FunctionType,
bool HasEvaluateWithGradient>
157 static void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
159 FunctionType::Gradient(coordinates, gradient);
167 template<
typename FunctionType>
177 static void Gradient(
const arma::mat& coordinates, arma::mat& gradient)
180 (void) FunctionType::EvaluateWithGradient(coordinates, gradient);
double(*)(const arma::mat &, arma::mat &) EvaluateWithGradientStaticForm
This is the form of a static EvaluateWithGradient() method.
void(*)(const arma::mat &, arma::mat &) GradientStaticForm
This is the form of a static Gradient() method.
static double EvaluateWithGradient(traits::UnconstructableType &, const size_t, const size_t)
void(FunctionType::*)(const arma::mat &, arma::mat &) const GradientConstForm
This is the form of a const Gradient() method.
double(FunctionType::*)(const arma::mat &, arma::mat &) const EvaluateWithGradientConstForm
This is the form of a const EvaluateWithGradient() method.
void Gradient(const arma::mat &coordinates, arma::mat &gradient)
Calculate the gradient and store it in the given matrix.
The AddGradient mixin class will provide a const Gradient() method if the given FunctionType has Eval...
The AddGradient mixin class will provide a static Gradient() method if the given FunctionType has sta...
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Gradient(traits::UnconstructableType &) const
void(FunctionType::*)(const arma::mat &, arma::mat &) GradientForm
This is the form of a non-const Gradient() method.
static void Gradient(traits::UnconstructableType &)
void Gradient(const arma::mat &coordinates, arma::mat &gradient)
static void Gradient(const arma::mat &coordinates, arma::mat &gradient)
void Gradient(const arma::mat &coordinates, arma::mat &gradient) const
Calculate the gradient and store it in the given matrix.
void Gradient(const arma::mat &coordinates, arma::mat &gradient) const
This is a utility type used to provide unusable overloads from each of the mixin classes.
void Gradient(traits::UnconstructableType &)
The AddGradient mixin class will provide a Gradient() method if the given FunctionType has EvaluateWi...
static void Gradient(const arma::mat &coordinates, arma::mat &gradient)
Calculate the gradient and store it in the given matrix.
double(FunctionType::*)(const arma::mat &, arma::mat &) EvaluateWithGradientForm
This is the form of a non-const EvaluateWithGradient() method.
The Function class is a wrapper class for any FunctionType that will add any possible derived methods...