120 vector<double> chi2(5, numeric_limits<double>::max());
123 return numeric_limits<double>::max();
128 const size_t N = this->size();
133 for (
size_t i = 0; i != N; ++i) {
143 DEBUG(
"chi2[0] " << setw(4) <<
numberOfIterations <<
' ' << FIXED(12,5) << chi2[0] << endl);
152 for (
double ds = 1.0; ds > 1.0e-3; ) {
154 this->
move(+1.0 * ds);
158 DEBUG(
"chi2[3] " << setw(4) << m <<
' ' << FIXED(12,5) << chi2[3] <<
' ' << FIXED(12,5) << ds << endl);
160 if (chi2[3] < chi2[2]) {
184 for ( ; m != 0; --m) {
185 this->
move(-1.0 * ds);
192 this->
move(-1.0 * ds);
194 if (chi2[2] < chi2[3]) {
202 const double f21 = chi2[2] - chi2[1];
203 const double f23 = chi2[2] - chi2[3];
205 const double xs = 0.5 * (f21 - f23) / (f23 + f21);
207 this->
move(+1.0 * xs * ds);
211 if (chi2[3] < chi2[2]) {
217 this->
move(-1.0 * xs * ds);
222 DEBUG(
"chi2[2] " << setw(4) <<
numberOfIterations <<
' ' << FIXED(12,5) << chi2[2] <<
' ' << SCIENTIFIC(12,5) << ds << endl);
232 if (fabs(chi2[2] - chi2[0]) <
epsilon * 0.5 * (fabs(chi2[0]) + fabs(chi2[2]))) {
244 for (
size_t i = 0; i != N; ++i){
255 for (
size_t i = 0; i != N; ++i){
257 H[i] = G[i] + dgg * H[i];
262 DEBUG(
"chi2[0] " << setw(4) <<
numberOfIterations <<
' ' << FIXED(12,5) << chi2[0] << endl);
287 const size_t N = this->size();
291 for (std::vector<double>::iterator i =
gradient.begin(); i !=
gradient.end(); ++i) {
299 for (
size_t i = 0; i != N; ++i) {
300 if ((*
this)[i].name.size() > width) {
301 width = (*this)[i].name.size();
307 for (
size_t i = 0; i != N; ++i) {
309 if ((*
this)[i].value != 0.0) {
311 (*this)[i]->apply(+0.5 * (*
this)[i].value);
315 (*this)[i]->apply(-0.5 * (*
this)[i].value);
316 (*this)[i]->apply(-0.5 * (*
this)[i].value);
322 (*this)[i]->apply(+0.5 * (*
this)[i].value);
324 DEBUG(setw(width) << left << (*
this)[i].name << right <<
' ' << FIXED(12,5) << (*
this)[i].value <<
' ' << FIXED(12,5) <<
gradient[i] << endl);
334 DEBUG(setw(width) << left <<
"|gradient|" << right <<
' ' << FIXED(12,5) << sqrt(V) << endl);