Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
ScalarFunction.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco, Mattia Piazza and Enrico Bertolazzi. *
3 * *
4 * The Optimist project is distributed under the BSD 2-Clause License. *
5 * *
6 * Davide Stocco Mattia Piazza Enrico Bertolazzi *
7 * University of Trento University of Trento University of Trento *
8 * davide.stocco@unitn.it mattia.piazza@unitn.it enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#pragma once
12
13#ifndef OPTIMIST_SCALAR_FUNCTION_HH
14#define OPTIMIST_SCALAR_FUNCTION_HH
15
16#include "Optimist/Function.hh"
17
18namespace Optimist
19{
20
29 template <typename Real, typename DerivedFunction>
30 class ScalarFunction : public Function<Real, 1, 1, DerivedFunction>
31 {
32 public:
34
39
44 std::string name() const {return static_cast<const DerivedFunction *>(this)->name_impl();}
45
51 void evaluate(Real x, Real & out) const
52 {
53 static_cast<const DerivedFunction *>(this)->evaluate_impl(x, out);
54 }
55
61 void first_derivative(Real x, Real & out) const
62 {
63 static_cast<const DerivedFunction *>(this)->first_derivative_impl(x, out);
64 }
65
71 void second_derivative(Real x, Real & out) const
72 {
73 static_cast<const DerivedFunction *>(this)->second_derivative_impl(x, out);
74 }
75
76 }; // class ScalarFunction
77
78} // namespace Optimist
79
80#endif // OPTIMIST_SCALAR_FUNCTION_HH
ScalarFunction()
Definition ScalarFunction.hh:38
void second_derivative(Real x, Real &out) const
Definition ScalarFunction.hh:71
std::string name() const
Definition ScalarFunction.hh:44
void evaluate(Real x, Real &out) const
Definition ScalarFunction.hh:51
void first_derivative(Real x, Real &out) const
Definition ScalarFunction.hh:61
Namespace for the Optimist library.
Definition Optimist.hh:87