Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Cos.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_TESTSET_COS_HH
14#define OPTIMIST_TESTSET_COS_HH
15
16#include "Optimist/TestSet.hh"
17
18namespace Optimist
19{
20
21 namespace TestSet
22 {
23
36 template <typename Real>
37 class Cos : public Function<Real, 1, 1, Cos<Real>>
38 {
39 public:
41
42
46 {
47 this->m_solutions.emplace_back(-M_PI/2.0); // Zero
48 this->m_solutions.emplace_back(M_PI/2.0); // Zero
49 this->m_solutions.emplace_back(-M_PI); // Minimum
50 this->m_solutions.emplace_back(M_PI); // Minimum
51 this->m_guesses.emplace_back(-3.0/8.0*M_PI);
52 this->m_guesses.emplace_back(3.0/8.0*M_PI);
53 }
54
59 std::string name_impl() const {return "Cos";}
60
66 void evaluate_impl(Real x, Real & out) const {out = std::cos(x);}
67
73 void first_derivative_impl(Real x, Real & out) const {out = -std::sin(x);}
74
80 void second_derivative_impl(Real x, Real & out) const {out = -std::cos(x);}
81
82 }; // class Cos
83
84 } // namespace TestSet
85
86} // namespace Optimist
87
88#endif // OPTIMIST_TESTSET_COS_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
std::vector< InputType > m_guesses
Definition Function.hh:63
std::vector< InputType > m_solutions
Definition Function.hh:62
void first_derivative_impl(Real x, Real &out) const
Definition Cos.hh:73
void evaluate_impl(Real x, Real &out) const
Definition Cos.hh:66
std::string name_impl() const
Definition Cos.hh:59
Cos()
Definition Cos.hh:45
void second_derivative_impl(Real x, Real &out) const
Definition Cos.hh:80
Namespace for the Optimist library.
Definition Optimist.hh:87