From: stevenj Date: Fri, 24 Aug 2007 21:52:20 +0000 (-0400) Subject: remove hard-coded limit on number of dimensions from DIRECT X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=828f22348c8ada141b4b82ce28ac8335c7761d00;p=nlopt.git remove hard-coded limit on number of dimensions from DIRECT darcs-hash:20070824215220-c8de0-0401f9ca597c5fbfacd7e38546a96a705278f283.gz --- diff --git a/direct/DIRect.c b/direct/DIRect.c index 9f02451..f686264 100644 --- a/direct/DIRect.c +++ b/direct/DIRect.c @@ -56,7 +56,6 @@ /* constants (FIXME: change to variable?) */ const integer MAXFUNC = 90000; const integer MAXDEEP = 600; - const integer MAXOR = 64; const integer MAXDIV = 3000; /* Local variables */ @@ -87,17 +86,17 @@ /* FIXME: change sizes dynamically? */ #define MY_ALLOC(p, t, n) p = (t *) malloc(sizeof(t) * (n)); \ if (!(p)) { *ierror = -100; goto cleanup; } - MY_ALLOC(c__, doublereal, MAXFUNC * MAXOR); + MY_ALLOC(c__, doublereal, MAXFUNC * (*n)); MY_ALLOC(f, doublereal, MAXFUNC * 2); MY_ALLOC(s, integer, MAXDIV * 2); - MY_ALLOC(w, doublereal, MAXOR); - MY_ALLOC(oldl, doublereal, MAXOR); - MY_ALLOC(oldu, doublereal, MAXOR); - MY_ALLOC(list2, integer, MAXOR * 2); + MY_ALLOC(w, doublereal, (*n)); + MY_ALLOC(oldl, doublereal, (*n)); + MY_ALLOC(oldu, doublereal, (*n)); + MY_ALLOC(list2, integer, (*n) * 2); MY_ALLOC(point, integer, MAXFUNC); MY_ALLOC(anchor, integer, MAXDEEP + 2); - MY_ALLOC(length, integer, MAXFUNC * MAXOR); - MY_ALLOC(arrayi, integer, MAXOR); + MY_ALLOC(length, integer, MAXFUNC * (*n)); + MY_ALLOC(arrayi, integer, (*n)); MY_ALLOC(levels, doublereal, MAXDEEP + 1); MY_ALLOC(thirds, doublereal, MAXDEEP + 1); @@ -389,7 +388,7 @@ /* +-----------------------------------------------------------------------+ */ direct_dirinit_(f, fcn, c__, length, &actdeep, point, anchor, &ifree, logfile, arrayi, &maxi, list2, w, &x[1], &l[1], &u[1], - fmin, &minpos, thirds, levels, &MAXFUNC, &MAXDEEP, n, &MAXOR, & + fmin, &minpos, thirds, levels, &MAXFUNC, &MAXDEEP, n, n, & fmax, &ifeasiblef, &iinfesiblef, ierror, fcn_data, jones); /* +-----------------------------------------------------------------------+ */ /* | Added error checking. | */ @@ -637,7 +636,7 @@ /* +-----------------------------------------------------------------------+ */ if (iinfesiblef > 0) { direct_dirreplaceinf_(&ifree, &ifreeold, f, c__, thirds, length, anchor, - point, &u[1], &l[1], &MAXFUNC, &MAXDEEP, &MAXOR, n, + point, &u[1], &l[1], &MAXFUNC, &MAXDEEP, n, n, logfile, &fmax, jones); } ifreeold = ifree;