chiark / gitweb /
Import nlopt_2.4.2+dfsg-8.debian.tar.xz
[nlopt.git] / patches / octave4.4.patch
1 Description: Fix FTBFS against Octave 4.4
2 Origin: backport, https://github.com/stevengj/nlopt/commit/1fcbcbf2fe8e34234e016cc43a6c41d3e8453e1f
3 Reviewed-by: Sébastien Villemot <sebastien@debian.org>
4 Last-Update: 2018-06-11
5 ---
6 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
7 --- a/octave/nlopt_optimize-oct.cc
8 +++ b/octave/nlopt_optimize-oct.cc
9 @@ -23,6 +23,7 @@
10  #include <octave/oct.h>
11  #include <octave/oct-map.h>
12  #include <octave/ov.h>
13 +#include <octave/parse.h>
14  #include <math.h>
15  #include <stdio.h>
16  
17 @@ -79,7 +80,12 @@ static double user_function(unsigned n,
18    for (unsigned i = 0; i < n; ++i)
19      xm(i) = x[i];
20    args(0) = xm;
21 -  octave_value_list res = data->f->do_multi_index_op(gradient ? 2 : 1, args); 
22 +  octave_value_list res
23 +#if (OCTAVE_MAJOR_VERSION == 4 && OCTAVE_MINOR_VERSION > 2)
24 +    = octave::feval(data->f, args, gradient ? 2 : 1);
25 +#else
26 +    = data->f->do_multi_index_op(gradient ? 2 : 1, args);
27 +#endif
28    if (res.length() < (gradient ? 2 : 1))
29      gripe_user_supplied_eval("nlopt_optimize");
30    else if (!res(0).is_real_scalar()
31 @@ -116,7 +122,12 @@ static double user_function1(unsigned n,
32    for (unsigned i = 0; i < n; ++i)
33      xm(i) = x[i];
34    args(0) = xm;
35 -  octave_value_list res = f->do_multi_index_op(gradient ? 2 : 1, args); 
36 +  octave_value_list res
37 +#if (OCTAVE_MAJOR_VERSION == 4 && OCTAVE_MINOR_VERSION > 2)
38 +    = octave::feval(f, args, gradient ? 2 : 1);
39 +#else
40 +    = f->do_multi_index_op(gradient ? 2 : 1, args);
41 +#endif
42    if (res.length() < (gradient ? 2 : 1))
43      gripe_user_supplied_eval("nlopt_optimize");
44    else if (!res(0).is_real_scalar()