Go to the source code of this file.
|
template<class T , class P > |
bool | Rminfc (T(*f)(P), P a, P b, double eps, double delta, P &x, P &y) |
|
template<class C , class T , class P > |
bool | RminfcM (const C &part, T(C::*f)(P) const, P a, P b, double eps, double delta, P &x, P &y) |
|
◆ Rminfc()
template<class T , class P >
bool Rminfc |
( |
T(*)(P) |
f, |
|
|
P |
a, |
|
|
P |
b, |
|
|
double |
eps, |
|
|
double |
delta, |
|
|
P & |
x, |
|
|
P & |
y |
|
) |
| |
Rminfc. Function which finds a single, local minimum of a function with one variable in a given interval. The "golden section search" is applied. The method uses a fixed number $n$ of function evaluations, where $n = [2.08\cdot\ln(|a-b|/\epsilon)+1/2] + 1$.
- Parameters
-
f | one-dimensional function |
a,b | end-points of search interval |
eps | accuracy parameter $\epsilon$ |
delta | tolerance interval $\delta$ near $a$ and $b$. Suggested value: $\delta = 10\epsilon$ |
x | computed approximation to the abscissa of a minimum of the function $f$ |
y | value of $f(x)$ |
44 {
45
46
48 static int n;
49 static P v,
w, fv, fw;
50 bool lge = true, llt = true;
51
52
53 n = -1;
56 }
60 c = b;
62 }
63
64 do {
66 if (llt == true) {
67 v = c + h * 0.3819660112501051;
68 fv = (*f)(v);
69 }
70 if (lge == true) {
71 w = c + h * 0.6180339887498949;
73 }
74 if (fv < fw) {
75 llt = true;
76 lge = false;
79 fw = fv;
80 } else {
81 llt = false;
82 lge = true;
83 c = v;
85 fv = fw;
86 }
87 --n;
88 } while (n >= 0);
89
91 y = (*f)(x);
92 return (
fabs(x -
a) > delta) && (
fabs(x - b) > delta);
93}
int round(const T &x)
Definition: Functions.hh:83
void d()
Definition: RecDispEX.C:381
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
void a()
Definition: check_aligned.C:59
void w(int rid=2, int nviews=2)
Definition: test.C:27
◆ RminfcM()
template<class C , class T , class P >
bool RminfcM |
( |
const C & |
part, |
|
|
T(C::*)(P) const |
f, |
|
|
P |
a, |
|
|
P |
b, |
|
|
double |
eps, |
|
|
double |
delta, |
|
|
P & |
x, |
|
|
P & |
y |
|
) |
| |
RminfcM. Rminfc version for const class member functions.
Function which finds a single, local minimum of a function with one variable in a given interval. The "golden section search" is applied. The method uses a fixed number $n$ of function evaluations, where $n = [2.08\cdot\ln(|a-b|/\epsilon)+1/2] + 1$.
- Parameters
-
f | one-dimensional function |
a,b | end-points of search interval |
eps | accuracy parameter $\epsilon$ |
delta | tolerance interval $\delta$ near $a$ and $b$. Suggested value: $\delta = 10\epsilon$ |
x | computed approximation to the abscissa of a minimum of the function $f$ |
y | value of $f(x)$ |
112 {
113
114
116 static int n;
117 static P v,
w, fv, fw;
118 bool lge = true, llt = true;
119
120
121 n = -1;
124 }
128 c = b;
130 }
131
132 do {
134 if (llt == true) {
135 v = c + h * 0.3819660112501051;
137 }
138 if (lge == true) {
139 w = c + h * 0.6180339887498949;
141 }
142 if (fv < fw) {
143 llt = true;
144 lge = false;
147 fw = fv;
148 } else {
149 llt = false;
150 lge = true;
151 c = v;
153 fv = fw;
154 }
155 --n;
156 } while (n >= 0);
157
160 return (
fabs(x -
a) > delta) && (
fabs(x - b) > delta);
161}
FILE * f
Definition: RecDispMC.C:150