Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Test11.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#ifndef OPTIMIST_TESTSET_TEST11_HH
12#define OPTIMIST_TESTSET_TEST11_HH
13
14#include "Optimist/TestSet.hh"
15
16namespace Optimist
17{
18
19 namespace TestSet
20 {
21
33 template <typename Real>
34 class Test11 : public Function<Real, 1, 1, Test11<Real>, true>
35 {
36 public:
38
39 using Vector = typename Function<Real, 1, 1, Test11<Real>, true>::InputVector;
40 using Matrix = typename Function<Real, 1, 1, Test11<Real>, true>::Matrix;
41 using Tensor = typename Function<Real, 1, 1, Test11<Real>, true>::Tensor;
42
47 {
48 this->m_solutions.emplace_back(-10.0);
49 this->m_solutions.emplace_back(-5.0);
50 this->m_solutions.emplace_back(0.0);
51 this->m_solutions.emplace_back(5.0);
52 this->m_solutions.emplace_back(10.0);
53 }
54
59 std::string name_impl() const {return "Test11";}
60
66 void evaluate_impl(const Vector & x, Vector & out) const
67 {
68 out << x(0) * x(0);
69 }
70
75 void first_derivative_impl(const Vector & x, Matrix & out) const
76 {
77 out << 2.0 * x(0);
78 }
79
85 void second_derivative_impl(const Vector & /*x*/, Tensor & out) const
86 {
87 out << 2.0;
88 }
89
90 }; // class Test11
91
92 } // namespace TestSet
93
94} // namespace Optimist
95
96#endif // OPTIMIST_TESTSET_TEST11_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
std::vector< InputType > m_solutions
Definition Function.hh:62
typename FunctionBase< Real, N, M, Test11< Real >, ForceEigen >::InputType InputVector
Definition Function.hh:193
void evaluate_impl(const Vector &x, Vector &out) const
Definition Test11.hh:66
std::string name_impl() const
Definition Test11.hh:59
typename Function< Real, 1, 1, Test11< Real >, true >::Matrix Matrix
Definition Test11.hh:40
Test11()
Definition Test11.hh:46
void first_derivative_impl(const Vector &x, Matrix &out) const
Definition Test11.hh:75
void second_derivative_impl(const Vector &, Tensor &out) const
Definition Test11.hh:85
typename Function< Real, 1, 1, Test11< Real >, true >::InputVector Vector
Definition Test11.hh:39
typename Function< Real, 1, 1, Test11< Real >, true >::Tensor Tensor
Definition Test11.hh:41
Namespace for the Optimist library test set functions.
Definition TestSet.hh:34
Namespace for the Optimist library.
Definition Optimist.hh:87