From 9e6ef20aa3475b9066962f9c4d48abc1be32cf96 Mon Sep 17 00:00:00 2001 From: stevenj Date: Mon, 14 Jun 2010 16:42:37 -0400 Subject: [PATCH] set_initial_step(opt, NULL) resets to default darcs-hash:20100614204237-c8de0-cd7a3a4bdbbd4d67c592fd103779f3a97aa51fc8.gz --- api/options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/options.c b/api/options.c index 5b80810..40e4791 100644 --- a/api/options.c +++ b/api/options.c @@ -486,7 +486,11 @@ nlopt_result nlopt_set_initial_step1(nlopt_opt opt, double dx) nlopt_result nlopt_set_initial_step(nlopt_opt opt, const double *dx) { unsigned i; - if (!opt || !dx) return NLOPT_INVALID_ARGS; + if (!opt) return NLOPT_INVALID_ARGS; + if (!dx) { + free(opt->dx); opt->dx = NULL; + return NLOPT_SUCCESS; + } for (i = 0; i < opt->n; ++i) if (dx[i] == 0) return NLOPT_INVALID_ARGS; if (!opt->dx && nlopt_set_initial_step1(opt, 1) == NLOPT_OUT_OF_MEMORY) return NLOPT_OUT_OF_MEMORY; -- 2.30.2