37 #ifndef GMM_ITER_SOLVERS_H__
38 #define GMM_ITER_SOLVERS_H__
50 template <
typename FUNC,
typename T>
52 T tol = gmm::default_tol(T())) {
53 T c, Ga = G(a), Gb = G(b), Gc, d;
56 for (
int i = 0; i < 4; i++) {
57 if (d < tol)
return (b + a) / 2.0;
58 c = b - Gb * (b - a) / (Gb - Ga); Gc = G(c);
59 a = b; b = c; Ga = Gb; Gb = Gc;
63 while (Ga * Gb > 0.0) {
64 if (d < tol)
return (b + a) / 2.0;
65 c = b - Gb * (b - a) / (Gb - Ga); Gc = G(c);
66 a = b; b = c; Ga = Gb; Gb = Gc;
70 c = std::max(a, b); a = std::min(a, b); b = c;
72 c = b - (b - a) * (Gb / (Gb - Ga));
76 if (Gc*Gb > 0) { b = c; Gb = Gc; }
else { a = c; Ga = Gc; }
77 c = (b + a) / 2.0 ; Gc = G(c);
78 if (Gc*Gb > 0) { b = c; Gb = Gc; }
else { a = c; Ga = Gc; }
79 d = gmm::abs(b - a); c = (b + a) / 2.0;
if ((c == a) || (c == b)) d = 0.0;
105 #include "gmm_least_squares_cg.h"
111 #endif // GMM_ITER_SOLVERS_H__