From: stevenj Date: Wed, 16 Nov 2011 19:20:13 +0000 (-0500) Subject: bug fix in preconditioned CCSA X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=80f299dd9738d6b23ac91f2e9c9390a5bfce9f7b;p=nlopt.git bug fix in preconditioned CCSA Ignore-this: fe3491084f60e094c208c260cf908084 darcs-hash:20111116192013-c8de0-b88c5b10cc4ab35d115d18522e1314503bb77e76.gz --- diff --git a/mma/ccsa_quadratic.c b/mma/ccsa_quadratic.c index eb3715b..1c829ce 100644 --- a/mma/ccsa_quadratic.c +++ b/mma/ccsa_quadratic.c @@ -173,7 +173,7 @@ static double gfunc(unsigned n, double f, const double *dfdx, val += 0.5 * dx[j] * Hdx[j]; if (grad) for (j = 0; j < n; ++j) - grad[j] = Hdx[j]; + grad[j] += Hdx[j]; } return val; @@ -289,13 +289,13 @@ nlopt_result ccsa_quadratic_minimize( no_precond = no_precond && dd.prec[i] == NULL; if (!no_precond) { - dd.scratch = (double*) malloc(sizeof(double) * (2*n)); + dd.scratch = (double*) malloc(sizeof(double) * (4*n)); if (!dd.scratch) { free(sigma); return NLOPT_OUT_OF_MEMORY; } - pre_lb = dual_lb; - pre_ub = dual_ub; + pre_lb = dd.scratch + 2*n; + pre_ub = pre_lb + n; pre_opt = nlopt_create(NLOPT_LD_CCSAQ, n); if (!pre_opt) { ret = NLOPT_FAILURE; goto done; }