Optimist
0.0.0
A C++ library for optimization
Toggle main menu visibility
Loading...
Searching...
No Matches
Halley.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_ROOTFINDER_HALLEY_HH
14
#define OPTIMIST_ROOTFINDER_HALLEY_HH
15
16
#include "
Optimist/RootFinder/OpenMethod.hh
"
17
18
namespace
Optimist
{
19
20
namespace
RootFinder {
21
29
template
<
typename
Scalar>
30
requires
TypeTrait<Scalar>::IsScalar
31
class
Halley
:
public
OpenMethod
<Scalar, Halley<Scalar>> {
32
public
:
33
static
constexpr
bool
RequiresFunction
{
true
};
34
static
constexpr
bool
RequiresFirstDerivative
{
true
};
35
static
constexpr
bool
RequiresSecondDerivative
{
true
};
36
37
OPTIMIST_BASIC_CONSTANTS
(
Scalar
)
38
39
42
Halley
() {}
43
48
constexpr
std::string
name_impl
()
const
{
49
return
"Halley"
;
50
}
51
64
template
<
typename
FunctionLambda>
65
Scalar
step_impl
([[maybe_unused]] FunctionLambda &function,
66
[[maybe_unused]]
const
Scalar
x,
67
const
Scalar
f,
68
const
Scalar
df,
69
[[maybe_unused]]
const
Scalar
ddf)
const
{
70
const
Scalar
newton{-f / df};
71
const
Scalar
L{f * ddf / (df * df)};
72
return
std::abs(L) < 1 ? newton / (1 - L / 2) : newton;
73
}
74
75
};
// class Halley
76
77
}
// namespace RootFinder
78
79
}
// namespace Optimist
80
81
#endif
// OPTIMIST_ROOTFINDER_HALLEY_HH
OpenMethod.hh
OPTIMIST_BASIC_CONSTANTS
#define OPTIMIST_BASIC_CONSTANTS(Scalar)
Definition
Optimist.hh:70
Optimist::RootFinder::Halley::step_impl
Scalar step_impl(FunctionLambda &function, const Scalar x, const Scalar f, const Scalar df, const Scalar ddf) const
Definition
Halley.hh:65
Optimist::RootFinder::Halley::RequiresFunction
static constexpr bool RequiresFunction
Definition
Halley.hh:33
Optimist::RootFinder::Halley::RequiresFirstDerivative
static constexpr bool RequiresFirstDerivative
Definition
Halley.hh:34
Optimist::RootFinder::Halley::name_impl
constexpr std::string name_impl() const
Definition
Halley.hh:48
Optimist::RootFinder::Halley::Halley
Halley()
Definition
Halley.hh:42
Optimist::RootFinder::Halley::RequiresSecondDerivative
static constexpr bool RequiresSecondDerivative
Definition
Halley.hh:35
Optimist::RootFinder::OpenMethod
Base class for the open (i.e., non-bracketing) one-dimensional root finders of Newton type.
Definition
OpenMethod.hh:46
Optimist::RootFinder::RootFinder< Scalar, Halley< Scalar > >::Scalar
typename TypeTrait< Scalar >::Scalar Scalar
Definition
RootFinder.hh:47
Optimist
Namespace for the Optimist library.
Definition
Optimist.hh:90
core
include
Optimist
RootFinder
Halley.hh
Generated by
1.18.0