提交 986c0d10 编写于 作者: S stevenj

work around broken solaris gcc

darcs-hash:20081122222958-c8de0-e8509a08196f53a05ba2c77513bd297c01f47637.gz
上级 16efd550
* Workaround for gcc 3.4.x conflict with HUGE_VAL definition in Solaris
(gcc bug 19933).
* Better identification of Matlab-plugin installation directory.
NLopt 1.0.1 (13 Nov. 2008)
* Allow user to override Matlab-plugin installation directory with
......
......@@ -23,7 +23,7 @@
#include <stdlib.h>
#include "nlopt.h"
#include "config.h"
#include "nlopt-util.h"
/*-----------------------------------------------------------------------*/
/* wrappers around f77 procedures */
......
......@@ -27,18 +27,11 @@
#include "nlopt.h"
#include "nlopt-util.h"
#include "config.h"
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/*************************************************************************/
#ifdef INFINITY
# define MY_INF INFINITY
#else
# define MY_INF HUGE_VAL
#endif
int nlopt_isinf(double x) {
return fabs(x) >= HUGE_VAL * 0.99
#ifdef HAVE_ISINF
......@@ -182,10 +175,10 @@ static double f_bound(int n, const double *x, void *data_)
discontinuous objectives so we can just return Inf for invalid x */
for (i = 0; i < n; ++i)
if (x[i] < data->lb[i] || x[i] > data->ub[i])
return MY_INF;
return HUGE_VAL;
f = data->f(n, x, NULL, data->f_data);
return (isnan(f) || nlopt_isinf(f) ? MY_INF : f);
return (isnan(f) || nlopt_isinf(f) ? HUGE_VAL : f);
}
static double f_noderiv(int n, const double *x, void *data_)
......@@ -306,7 +299,7 @@ static nlopt_result nlopt_minimize_(
stop.n = n;
stop.minf_max = (isnan(minf_max)
|| (nlopt_isinf(minf_max) && minf_max < 0))
? -MY_INF : minf_max;
? -HUGE_VAL : minf_max;
stop.ftol_rel = ftol_rel;
stop.ftol_abs = ftol_abs;
stop.xtol_rel = xtol_rel;
......
......@@ -28,7 +28,6 @@
#include "nlopt.h"
#include "cdirect.h"
#include "redblack.h"
#include "config.h"
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
......
......@@ -28,7 +28,6 @@
#include "nlopt.h"
#include "cdirect.h"
#include "redblack.h"
#include "config.h"
/* Hybrid algorithm, inspired by DIRECT, that uses another local
* optimization algorithm within each rectangle, and then looks
......
dnl Process this file with autoconf to produce a configure script.
AC_INIT(nlopt, 1.0.1, stevenj@alum.mit.edu)
AC_INIT(nlopt, 1.0.2, stevenj@alum.mit.edu)
AC_CONFIG_SRCDIR(api/nlopt.h)
SHARED_VERSION_INFO="0:1:0" # CURRENT:REVISION:AGE
SHARED_VERSION_INFO="0:2:0" # CURRENT:REVISION:AGE
AM_INIT_AUTOMAKE(1.7)
AM_CONFIG_HEADER(config.h)
......@@ -165,6 +165,23 @@ AC_SUBST(MEX_INSTALL_DIR)
AC_SUBST(MEX)
AC_SUBST(MEXSUFF)
dnl -----------------------------------------------------------------------
dnl Check for broken Solaris HUGE_VAL macro under gcc 3.4.x and similar
AC_MSG_CHECKING([for working HUGE_VAL])
AC_TRY_COMPILE([#include <math.h>], [double x = -HUGE_VAL;],
[AC_MSG_RESULT([ok])],
[AC_TRY_COMPILE([#include <math.h>
#ifdef __GNUC__
#undef HUGE_VAL
#define HUGE_VAL __builtin_huge_val()
#endif], [double x = -HUGE_VAL;],
[AC_MSG_RESULT([__builtin_huge_val()])
AC_DEFINE(REPLACEMENT_HUGE_VAL,[__builtin_huge_val()],
[replacement for broken HUGE_VAL macro, if needed])],
[AC_MSG_RESULT([unknown])
AC_MSG_ERROR([broken HUGE_VAL macro with this compiler, unknown workaround])])])
dnl -----------------------------------------------------------------------
dnl Debugging
......
AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
noinst_LTLIBRARIES = libdirect.la
libdirect_la_SOURCES = DIRect.c direct_wrap.c DIRserial.c DIRsubrout.c \
direct-internal.h direct.h
......
......@@ -6,6 +6,7 @@
#include <math.h>
#include "direct.h"
#include "nlopt-util.h"
#ifdef __cplusplus
extern "C"
......
......@@ -26,7 +26,7 @@
#include <stdio.h>
#include "mma.h"
#include "config.h"
#include "nlopt-util.h"
int mma_verbose = 0; /* > 0 for verbose output */
......
AM_CPPFLAGS = -I$(top_srcdir)/api
AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util
MFILES = NLOPT_GN_DIRECT.m NLOPT_GN_DIRECT_L.m NLOPT_GN_DIRECT_L_RAND.m NLOPT_GN_DIRECT_NOSCAL.m NLOPT_GN_DIRECT_L_NOSCAL.m NLOPT_GN_DIRECT_L_RAND_NOSCAL.m NLOPT_GN_ORIG_DIRECT.m NLOPT_GN_ORIG_DIRECT_L.m NLOPT_GD_STOGO.m NLOPT_GD_STOGO_RAND.m NLOPT_LD_LBFGS_NOCEDAL.m NLOPT_LD_LBFGS.m NLOPT_LN_PRAXIS.m NLOPT_LD_VAR1.m NLOPT_LD_VAR2.m NLOPT_LD_TNEWTON.m NLOPT_LD_TNEWTON_RESTART.m NLOPT_LD_TNEWTON_PRECOND.m NLOPT_LD_TNEWTON_PRECOND_RESTART.m NLOPT_GN_CRS2_LM.m NLOPT_GN_MLSL.m NLOPT_GD_MLSL.m NLOPT_GN_MLSL_LDS.m NLOPT_GD_MLSL_LDS.m NLOPT_LD_MMA.m NLOPT_LN_COBYLA.m NLOPT_LN_NEWUOA.m NLOPT_LN_NEWUOA_BOUND.m NLOPT_LN_NELDERMEAD.m NLOPT_LN_SBPLX.m
#######################################################################
# dummy C program to fool automake into making sure that CPPFLAGS etc.
# are all defined
noinst_PROGRAMS = dummy
dummy_SOURCES = dummy.c
#######################################################################
octdir = $(OCT_INSTALL_DIR)
mdir = $(M_INSTALL_DIR)
......
#include <stdio.h>
int main(void) { printf("Hello world.\n"); return 0; }
......@@ -29,6 +29,7 @@
#include <mex.h>
#include "nlopt.h"
#include "nlopt-util.h"
#define xSTRIZE(x) #x
#define STRIZE(x) xSTRIZE(x)
......
......@@ -46,7 +46,6 @@
*/
#include "nlopt-util.h"
#include "config.h"
#if defined(HAVE_STDINT_H)
# include <stdint.h>
......
......@@ -24,6 +24,14 @@
#define NLOPT_UTIL_H
#include <stdlib.h>
#include <math.h>
#include "config.h"
/* workaround for Solaris + gcc 3.4.x bug (see configure.ac) */
#if defined(__GNUC__) && defined(REPLACEMENT_HUGE_VAL)
# undef HUGE_VAL
# define HUGE_VAL REPLACEMENT_HUGE_VAL
#endif
#ifdef __cplusplus
extern "C"
......
......@@ -20,8 +20,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <nlopt-util.h>
#include "config.h"
#include "nlopt-util.h"
/* Simple replacement for the BSD qsort_r function (re-entrant sorting),
if it is not available. (It looks like glibc 2.8 will include qsort_r
......
......@@ -26,6 +26,13 @@
#include <time.h>
#include "redblack.h"
#include "config.h"
/* workaround for Solaris + gcc 3.4.x bug (see configure.ac) */
#if defined(__GNUC__) && defined(REPLACEMENT_HUGE_VAL)
# undef HUGE_VAL
# define HUGE_VAL REPLACEMENT_HUGE_VAL
#endif
static int comp(rb_key k1, rb_key k2)
{
if (*k1 < *k2) return -1;
......
......@@ -47,11 +47,10 @@
a free/open-source implementation. */
#include <stdlib.h>
#include <math.h>
#include "nlopt-util.h"
#include "config.h"
#if defined(HAVE_STDINT_H)
# include <stdint.h>
#endif
......@@ -250,7 +249,6 @@ void nlopt_sobol_skip(nlopt_sobol s, unsigned n, double *x)
/* compile with -DSOBOLSEQ_TEST for test program */
#ifdef SOBOLSEQ_TEST
#include <stdio.h>
#include <math.h>
#include <time.h>
/* test integrand from Joe and Kuo paper ... integrates to 1 */
......
......@@ -21,7 +21,6 @@
*/
#include "nlopt-util.h"
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册