Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 565508
Collapse All | Expand All

(-)a/octave/nlopt_optimize-oct.cc (-6 / +6 lines)
Lines 29-35 Link Here
29
#include "nlopt.h"
29
#include "nlopt.h"
30
#include "nlopt_optimize_usage.h"
30
#include "nlopt_optimize_usage.h"
31
31
32
static int struct_val_default(Octave_map &m, const std::string& k,
32
static int struct_val_default(octave_map &m, const std::string& k,
33
				 int dflt)
33
				 int dflt)
34
{
34
{
35
  if (m.contains(k)) {
35
  if (m.contains(k)) {
Lines 39-45 static int struct_val_default(Octave_map &m, const std::string& k, Link Here
39
  return dflt;
39
  return dflt;
40
}
40
}
41
41
42
static double struct_val_default(Octave_map &m, const std::string& k,
42
static double struct_val_default(octave_map &m, const std::string& k,
43
				 double dflt)
43
				 double dflt)
44
{
44
{
45
  if (m.contains(k)) {
45
  if (m.contains(k)) {
Lines 49-55 static double struct_val_default(Octave_map &m, const std::string& k, Link Here
49
  return dflt;
49
  return dflt;
50
}
50
}
51
51
52
static Matrix struct_val_default(Octave_map &m, const std::string& k,
52
static Matrix struct_val_default(octave_map &m, const std::string& k,
53
				 Matrix &dflt)
53
				 Matrix &dflt)
54
{
54
{
55
  if (m.contains(k)) {
55
  if (m.contains(k)) {
Lines 140-146 static double user_function1(unsigned n, const double *x, Link Here
140
140
141
#define CHECK1(cond, msg) if (!(cond)) { fprintf(stderr, msg "\n\n"); nlopt_destroy(opt); nlopt_destroy(local_opt); return NULL; }
141
#define CHECK1(cond, msg) if (!(cond)) { fprintf(stderr, msg "\n\n"); nlopt_destroy(opt); nlopt_destroy(local_opt); return NULL; }
142
142
143
nlopt_opt make_opt(Octave_map &opts, int n)
143
nlopt_opt make_opt(octave_map &opts, int n)
144
{
144
{
145
  nlopt_opt opt = NULL, local_opt = NULL;
145
  nlopt_opt opt = NULL, local_opt = NULL;
146
146
Lines 195-201 nlopt_opt make_opt(Octave_map &opts, int n) Link Here
195
    CHECK1(opts.contents("local_optimizer").length() == 1 
195
    CHECK1(opts.contents("local_optimizer").length() == 1 
196
	  && (opts.contents("local_optimizer"))(0).is_map(),
196
	  && (opts.contents("local_optimizer"))(0).is_map(),
197
	  "opt.local_optimizer must be a structure");
197
	  "opt.local_optimizer must be a structure");
198
    Octave_map local_opts = (opts.contents("local_optimizer"))(0).map_value();
198
    octave_map local_opts = (opts.contents("local_optimizer"))(0).map_value();
199
    CHECK1((local_opt = make_opt(local_opts, n)), 
199
    CHECK1((local_opt = make_opt(local_opts, n)), 
200
	  "error initializing local optimizer");
200
	  "error initializing local optimizer");
201
    nlopt_set_local_optimizer(opt, local_opt);
201
    nlopt_set_local_optimizer(opt, local_opt);
Lines 216-222 DEFUN_DLD(nlopt_optimize, args, nargout, NLOPT_OPTIMIZE_USAGE) Link Here
216
  CHECK(args.length() == 2 && nargout <= 3, "wrong number of args");
216
  CHECK(args.length() == 2 && nargout <= 3, "wrong number of args");
217
217
218
  CHECK(args(0).is_map(), "opt must be structure")
218
  CHECK(args(0).is_map(), "opt must be structure")
219
  Octave_map opts = args(0).map_value();
219
  octave_map opts = args(0).map_value();
220
220
221
  CHECK(args(1).is_real_matrix() || args(1).is_real_scalar(),
221
  CHECK(args(1).is_real_matrix() || args(1).is_real_scalar(),
222
	"x must be real vector");
222
	"x must be real vector");

Return to bug 565508