Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Cosh.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco and Enrico Bertolazzi. *
3 * *
4 * The Optimist project is distributed under the BSD 2-Clause License. *
5 * *
6 * Davide Stocco Enrico Bertolazzi *
7 * University of Trento University of Trento *
8 * davide.stocco@unitn.it enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#pragma once
12
13#ifndef OPTIMIST_TESTSET_COSH_HH
14#define OPTIMIST_TESTSET_COSH_HH
15
16#include "Optimist/Function.hh"
17
18namespace Optimist {
19
20 namespace TestSet {
21
34 template <typename Scalar>
35 requires TypeTrait<Scalar>::IsScalar
36 class Cosh : public Function<Scalar, Scalar, Cosh<Scalar>> {
37 public:
39
40
43 Cosh() {
44 this->m_solutions.emplace_back(0.0); // Minimum
45 this->m_guesses.emplace_back(-1.0);
46 this->m_guesses.emplace_back(1.0);
47 }
48
53 constexpr std::string name_impl() const {
54 return "Cosh";
55 }
56
63 bool evaluate_impl(const Scalar x, Scalar &out) const {
64 out = std::cosh(x);
65 return std::isfinite(out);
66 }
67
74 bool first_derivative_impl(const Scalar x, Scalar &out) const {
75 out = std::sinh(x);
76 return std::isfinite(out);
77 }
78
85 bool second_derivative_impl(const Scalar x, Scalar &out) const {
86 out = std::cosh(x);
87 return std::isfinite(out);
88 }
89
90 }; // class Cosh
91
92 } // namespace TestSet
93
94} // namespace Optimist
95
96#endif // OPTIMIST_TESTSET_COSH_HH
#define OPTIMIST_BASIC_CONSTANTS(Scalar)
Definition Optimist.hh:70
typename InputTrait::Scalar Scalar
Definition Function.hh:53
std::vector< Scalar > m_guesses
Definition Function.hh:79
std::vector< Scalar > m_solutions
Definition Function.hh:77
Cosh()
Definition Cosh.hh:43
constexpr std::string name_impl() const
Definition Cosh.hh:53
bool evaluate_impl(const Scalar x, Scalar &out) const
Definition Cosh.hh:63
bool first_derivative_impl(const Scalar x, Scalar &out) const
Definition Cosh.hh:74
bool second_derivative_impl(const Scalar x, Scalar &out) const
Definition Cosh.hh:85
Namespace for the Optimist library.
Definition Optimist.hh:90