Skip to content

Commit

Permalink
Merge pull request #77 from HunterTracer/master
Browse files Browse the repository at this point in the history
Fix wrong hessian order in amplgsl.cc and gsl-test.cc
  • Loading branch information
fdabrandao authored Oct 30, 2023
2 parents b58a9ab + 9c42644 commit a539555
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ampl/src/amplgsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ static double amplgsl_hypot3(arglist *al) {
double dz2 = derivs[2] * derivs[2];
hes[0] = (dy2 + dz2) / hypot;
hes[1] = -derivs[0] * derivs[1] / hypot;
hes[2] = -derivs[0] * derivs[2] / hypot;
hes[3] = (dx2 + dz2) / hypot;
hes[2] = (dx2 + dz2) / hypot;
hes[3] = -derivs[0] * derivs[2] / hypot;
hes[4] = -derivs[1] * derivs[2] / hypot;
hes[5] = (dx2 + dy2) / hypot;
}
Expand Down
2 changes: 1 addition & 1 deletion ampl/test/gsl-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void GSLTest::CheckSecondDerivatives(F f, const Function &af,
if (!gsl_isnan(d)) {
unsigned ii = i, jj = j;
if (ii > jj) std::swap(ii, jj);
unsigned hes_index = ii * (2 * num_args - ii - 1) / 2 + jj;
unsigned hes_index = ii + jj * (jj + 1) / 2;
double actual_deriv = af(args, HES, use_deriv).hes(hes_index);
if (!CheckDerivative(actual_deriv, d, error)) {
std::cout << "Absolute tolerance of "
Expand Down

0 comments on commit a539555

Please sign in to comment.