Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Sin.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_SIN_HH
14#define OPTIMIST_SCALAR_FUNCTION_SIN_HH
15
16#include "Optimist/TestSet.hh"
18
19namespace Optimist
20{
21
22 namespace TestSet
23 {
24
37 template <typename Real>
38 class Sin : public ScalarFunction<Real, Sin<Real>>
39 {
40 public:
42
43
47 {
48 this->m_solutions.emplace_back(-M_PI); // Zero
49 this->m_solutions.emplace_back(0.0); // Zero
50 this->m_solutions.emplace_back(M_PI); // Zero
51 this->m_solutions.emplace_back(-M_PI/2.0); // Minimum
52 this->m_guesses.emplace_back(-0.8*M_PI);
53 this->m_guesses.emplace_back(0.8*M_PI);
54 }
55
60 std::string name_impl() const {return "Sin";}
61
67 void evaluate_impl(Real x, Real & out) const {out = std::sin(x);}
68
74 void first_derivative_impl(Real x, Real & out) const {out = std::cos(x);}
75
81 void second_derivative_impl(Real x, Real & out) const {out = -std::sin(x);}
82
83 }; // class Sin
84
85 } // namespace TestSet
86
87} // namespace Optimist
88
89#endif // OPTIMIST_SCALAR_FUNCTION_SIN_HH
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
std::vector< InputType > m_solutions
Definition Function.hh:52
std::vector< InputType > m_guesses
Definition Function.hh:53
ScalarFunction()
Definition ScalarFunction.hh:38
std::string name_impl() const
Definition Sin.hh:60
void second_derivative_impl(Real x, Real &out) const
Definition Sin.hh:81
void first_derivative_impl(Real x, Real &out) const
Definition Sin.hh:74
void evaluate_impl(Real x, Real &out) const
Definition Sin.hh:67
Sin()
Definition Sin.hh:46
Namespace for the Optimist library.
Definition Optimist.hh:87