Commit 1b0a7a92 authored by Davis King's avatar Davis King

Moved negate_function() to a different file to avoid an #include ordering bug

that happened when using find_max_single_variable().
parent 53aff1c8
......@@ -102,27 +102,6 @@ namespace dlib
return central_differences<funct>(f,eps);
}
// ----------------------------------------------------------------------------------------
template <typename funct>
class negate_function_object
{
public:
negate_function_object(const funct& f_) : f(f_){}
template <typename T>
double operator()(const T& x) const
{
return -f(x);
}
private:
const funct& f;
};
template <typename funct>
const negate_function_object<funct> negate_function(const funct& f) { return negate_function_object<funct>(f); }
// ----------------------------------------------------------------------------------------
template <typename funct, typename EXP1, typename EXP2>
......
......@@ -68,22 +68,6 @@ namespace dlib
- returns derivative(f, 1e-7)
!*/
// ----------------------------------------------------------------------------------------
template <
typename funct
>
const negate_function_object<funct> negate_function(
const funct& f
);
/*!
requires
- f == a function that returns a scalar
ensures
- returns a function that represents the negation of f. That is,
the returned function object represents g(x) == -f(x)
!*/
// ----------------------------------------------------------------------------------------
template <
......
......@@ -807,6 +807,27 @@ namespace dlib
return f2;
}
// ----------------------------------------------------------------------------------------
template <typename funct>
class negate_function_object
{
public:
negate_function_object(const funct& f_) : f(f_){}
template <typename T>
double operator()(const T& x) const
{
return -f(x);
}
private:
const funct& f;
};
template <typename funct>
const negate_function_object<funct> negate_function(const funct& f) { return negate_function_object<funct>(f); }
// ----------------------------------------------------------------------------------------
template <typename funct>
......
......@@ -249,6 +249,22 @@ namespace dlib
value from this function.
!*/
// ----------------------------------------------------------------------------------------
template <
typename funct
>
const negate_function_object<funct> negate_function(
const funct& f
);
/*!
requires
- f == a function that returns a scalar
ensures
- returns a function that represents the negation of f. That is,
the returned function object represents g(x) == -f(x)
!*/
// ----------------------------------------------------------------------------------------
class optimize_single_variable_failure : public error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment